系统环境:
[root@zhaochj ~]# cat /etc/issue CentOS release 6.4 (Final) Kernel \r on an \m [root@zhaochj ~]# uname -r 2.6.32-358.el6.x86_64
软件包列表:(点击获取:http://pan.baidu.com/s/1gdqyvB1)
apr-1.5.1.tar.gz apr-util-1.5.2.tar.bz2 httpd-2.4.10.tar.bz2
安装pcre:
[root@zhaochj ~]# yum -y install pcre-devel
安装高版本的apr:(编译时出错rm: cannot remove `libtoolT': No such file or directory,处理方法请见http://www.92cto.com/blog/863.html)
[root@zhaochj httpd2.4]# pwd /root/software/httpd2.4 [root@zhaochj httpd2.4]# ls apr-1.5.1.tar.gz apr-util-1.5.2.tar.bz2 httpd-2.4.10.tar.bz2 [root@zhaochj httpd2.4]# tar -xf apr-1.5.1.tar.gz [root@zhaochj httpd2.4]# cd apr-1.5.1 [root@zhaochj apr-1.5.1]# ./configure --prefix=/usr/local/apr-1.5 [root@zhaochj apr-1.5.1]# make && make install
安装高版本的apr-util:
[root@zhaochj httpd2.4]# tar xf apr-util-1.5.2.tar.bz2 [root@zhaochj httpd2.4]# cd apr-util-1.5.2 [root@zhaochj apr-util-1.5.2]# ./configure --prefix=/usr/local/apr-util-1.5 --with-apr=/usr/local/apr-1.5 [root@zhaochj apr-util-1.5.2]# make && make install
安装httpd2.4:
[root@zhaochj httpd2.4]# tar xf httpd-2.4.10.tar.bz2 [root@zhaochj httpd2.4]# cd httpd-2.4.10 [root@zhaochj httpd2.4.10]# ./configure --prefix=/usr/local/apache24 --sysconfdir=/etc/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr-1.5 --with-apr-util=/usr/local/apr-util-1.5 --enable-modules=most --enable-mpms-shared=all --with-mpm=event [root@zhaochj httpd2.4.10]# make && make install
配置本地主机解析:
[root@zhaochj httpd-2.4.10]# echo "192.168.0.200 zhaochj" >> /etc/hosts
配置主配置文件的ServerName:
[root@zhaochj httpd-2.4.10]# vim /etc/httpd24/httpd.conf ServerName 192.168.0.200:80 #修改ServerName段为这样,根据主机的实际ip配置
启用服务及验证所用mpm:
[root@zhaochj httpd-2.4.10]# /usr/local/apache24/bin/apachectl -k start [root@zhaochj httpd-2.4.10]# /usr/local/apache24/bin/apachectl -t -D DUMP_MODULES
导出头文件:
[root@zhaochj httpd2.4]# ln -sv /usr/local/apache24/include /usr/include/http2.4
导出二进制文件:
[root@zhaochj httpd2.4]# vim /etc/profile.d/httpd24.sh export PATH=/usr/local/apache24/bin:$PATH [root@zhaochj httpd2.4]# source /etc/profile.d/httpd24.sh
说明:如果系统已安装过rpm包的httpd,用apachect1启动httpd服务器有可能启动的是rpm包的程序,可用hash命令查看到底是用的rpm包的apachect1还是/usr/local/httpd2.4/bin下的apachectl程序,如果与预期不同,可以卸载rpm包的httpd,或调整PATH变量。
启动、停止httpd:
[root@zhaochj httpd2.4]# apachectl start [root@zhaochj httpd2.4]# apachectl stop
以脚本方式来管理源码安装的httpd:
借用原系统中用yum方式安装的httpd 2.2的服务脚本来作相应修改即可。
[root@zhaochj init.d]# pwd /etc/rc.d/init.d [root@zhaochj init.d]# cp httpd httpd24 [root@zhaochj init.d]# vim httpd24 #修改以下的变量为源码安装的路径 apachectl=/usr/local/apache24/sbin/apachectl httpd=${HTTPD-/usr/local/apache24/bin/httpd} prog=httpd pidfile=${PIDFILE-/usr/local/apache24/logs/httpd.pid}
脚本方式服务的管理:
[root@bogon init.d]# chkconfig --add httpd24 [root@bogon init.d]# service httpd24 start [root@bogon init.d]# service httpd24 stop [root@bogon init.d]# service httpd24 restart