操作环境:RedHat Enterprise Linux 5.6
一、安装准备
安装Apache一般依赖3个组件:apr、apr-util、pcre。
确保这三个组件已经安装。
[root@bigsrv ~]# rpm -qa|grep apr
apr-util-1.2.7-11.el5_5.2
apr-1.2.7-11.el5_5.3
apr-1.2.7-11.el5_5.3
xorg-x11-drv-dynapro-1.1.0-2
apr-util-1.2.7-11.el5_5.2
[root@bigsrv ~]# rpm -qa|grep pcre
pcre-6.6-6.el5
如果没有安装,则通过如下方式通过源码安装。
安装apr:
tar -zxf apr-1.6.2.tar.gz
./configure --prefix=/usr/local/apr
make
make install
安装apr-util:
tar -zxf apr-util-1.6.0.tar.gz
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
make
make install
安装pcre:
unzip pcre2-10.30.zip
cd pcre2-10.30
./configure --prefix=/usr/local/pcre
make
make install
二、安装Apache2
如果操作系统已经具有了安装的组件,通过以下命令安装:
./configure --prefix=/usr/local/apache2 --enable-so --enable-proxy --enable-proxy-ajp --enable-proxy-http --enable-proxy-ftp --enable-proxy-connect --enable-proxy-balancers
make
make install
如果是单独编译安装的组件,则通过以下命令安装:
./configure --prefix=/usr/local/apache2 --enable-so --enable-proxy --enable-proxy-ajp --enable-proxy-http --enable-proxy-ftp --enable-proxy-connect --enable-proxy-balancers --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre
make
make install
安装完成后的路径及目录如下:
[root@bigsrv apache2]# pwd
/usr/local/apache2
[root@bigsrv apache2]# ll
total 112
drwxr-xr-x 2 root root 4096 Nov 8 07:56 bin
drwxr-xr-x 2 root root 4096 Nov 8 07:56 build
drwxr-xr-x 2 root root 4096 Nov 8 07:56 cgi-bin
drwxr-xr-x 4 root root 4096 Nov 8 07:56 conf
drwxr-xr-x 3 root root 4096 Nov 8 07:56 error
drwxr-xr-x 2 root root 4096 Jun 28 2013 htdocs
drwxr-xr-x 3 root root 4096 Nov 8 07:56 icons
drwxr-xr-x 2 root root 4096 Nov 8 07:56 include
drwxr-xr-x 3 root root 4096 Nov 8 07:56 lib
drwxr-xr-x 2 root root 4096 Nov 8 07:56 logs
drwxr-xr-x 4 root root 4096 Nov 8 07:56 man
drwxr-xr-x 14 root root 12288 Jun 28 2013 manual
drwxr-xr-x 2 root root 4096 Nov 8 07:56 modules
[root@bigsrv apache2]#
三、Apache2基本操作
启动停止命令:
[root@bigsrv bin]# pwd
/usr/local/apache2/bin
[root@bigsrv bin]# ./apachectl start
httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.101.100 for ServerName
[root@bigsrv bin]# ./apachectl stop
httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.101.100 for ServerName
[root@bigsrv bin]#
去除启动或停止时“server's fully qualified domain name提示”:
在/usr/local/apache2/conf/httpd.conf配置文件中搜索“ServerName”关键字,去掉前面的“#”并修改后面的主机名即可。
如:ServerName 192.168.101.100:80
修改后重启服务发现没有相关提示。
[root@bigsrv bin]# ./apachectl stop
[root@bigsrv bin]# ./apachectl start