Warning: Missing argument 2 for wp_widget() in /www/users/haoxm.net/wp-includes/widgets.php on line 76
孤独小客 » Blog Archive » CentOS5.5下安装apache

CentOS5.5下安装apache

实验目的:学会安装LAMP之apache
实验环境:CentOS 5.5 32位
实验人:孤独小客
实验时间:2010年12月5号
软件版本:httpd-2.2.4.tar.gz

1、把下载下来的软件解压一下
[root@haoxm soft]# tar zxvf httpd-2.2.4.tar.gz
2、进入刚解压的目录
[root@haoxm soft]# cd httpd-2.2.4
[root@haoxm httpd-2.2.4]#
3、配置apache
[root@haoxm httpd-2.2.4]# ./configure –prefix=/usr/local/apache –

enable-so
(如果不喜欢这样连着写,也可以换行写,如下面:
[root@haoxm httpd-2.2.4]# ./configure \
> –prefix=/usr/local/apache \
> –enable-so
)
4、配置成功后会跳到如下的界面,而且此目录下用ls查看文件,会多了一个

Makefile文件。
[root@haoxm httpd-2.2.4]#
[root@haoxm httpd-2.2.4]# ls
ABOUT_APACHE config.nice InstallBin.dsp NWGNUmakefile
acinclude.m4 config.status LAYOUT os
Apache.dsw configure libhttpd.dsp README
apachenw.mcp.zip configure.in LICENSE README.platforms
build docs Makefile ROADMAP
BuildBin.dsp emacs-style Makefile.in server
buildconf httpd.dsp Makefile.win srclib
CHANGES httpd.spec modules support
config.layout include modules.c test
config.log INSTALL NOTICE VERSIONING

5、然后编辑make,有人说在make之前用make clean清理之前有编译过东西留下的

垃圾,如果你系统之前还没编译过其他东西就不用了。
[root@haoxm httpd-2.2.4]# make
如果make成功后会是下面这样的,没有出错
make[1]: Leaving directory `/root/soft/httpd-2.2.4′
[root@haoxm httpd-2.2.4]#
6、安装
[root@haoxm httpd-2.2.4]# make install
注:如果安装成功后,一般是下面这样的,没有一点出错。

mkdir /usr/local/apache/man
mkdir /usr/local/apache/man/man1
mkdir /usr/local/apache/man/man8
mkdir /usr/local/apache/manual
make[1]: Leaving directory `/root/soft/httpd-2.2.4′
[root@haoxm httpd-2.2.4]#

7、安装后再运行下make clean就可以。
8、启动apache
[root@haoxm httpd-2.2.4]# /usr/local/apache/bin/apachectl start
httpd: Could not reliably determine the server’s fully qualified domain

name, using haoxm.net for ServerName
(出错,晕。查了资料说把httpd.conf里面的ServerName www.example.com:80注释

去掉就可以,我就试着改成ServerName www.RedHat.com:80,再启动apache就可

以。
输入http://192.168.0.110自己的机子上试,这时正常的话会提示It Works!)

9、把启动文件拷到/etc/init.d/目录下,以后启动就比较方便
[root@haoxm httpd-2.2.4]# cp /usr/local/apache/bin/apachectl

/etc/init.d/httpd
[root@haoxm httpd-2.2.4]# /etc/init.d/httpd restart
10、把apache添加到服务里面
[root@haoxm httpd-2.2.4]# cd /etc/init.d/
[root@haoxm init.d]# ll httpd
-rwxr-xr-x 1 root root 3425 Dec 5 16:17 httpd
[root@haoxm init.d]# chkconfig –add httpd
service httpd does not support chkconfig
注:如果这样直接添加就会显示httpd不支持chkconfig,
解决方法:
编辑/etc/init.d/httpd
在#!/bin/sh后面加入下面两行
[root@haoxm init.d]# vi /etc/init.d/httpd
#!/bin/sh
#chkconfig:345 85 15
#description:start and stops the apache http server.
保存下,再次执行下面命令就可以。
[root@haoxm init.d]# chkconfig –add httpd

Leave a comment

Your comment