源码安装apache,路径 /usr/local/httpd24 1.安装apr yum -y install epel-release wget -c http://archive.apache.org/dist/apr/apr-1.5.2.tar.gz tar xf apr-1.5.2.tar.gz cd apr-1.5.2 ./configure --prefix=/usr/local/apr;echo $? make && make install;echo $? cd .. 2.安装apr-util wget -c http://archive.apache.org/dist/apr/apr-util-1.5.2.tar.gz tar xf apr-util-1.5.2.tar.gz cd apr-util-1.5.2 ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr;echo $? make && make install;echo $? 3.安装httpd2.4.12 yum install pcre-devel openssl-devel wget -c http://www.apache.org/dist/httpd/httpd-2.4.12.tar.gz tar xf httpd-2.4.12.tar.gz cd httpd-2.4.12 ./configure --prefix=/usr/local/httpd24 --sysconfdir=/etc/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --enable-modules=most --enable-mpms-shared=all --with-mpm=event;echo $? make && make install;echo $? 4.测试 /usr/local/apache24/bin/apachectl start netstat -utl |grep http 出现 0 *:http *:* LISTEN 浏览器访问centos机器IP,出现It works! 5.添加到系统服务实现开机启动: cp /usr/local/httpd24/bin/apachectl /etc/init.d/httpd
vim /etc/init.d/httpd 在文件开头加入下面几行: #!/bin/sh # chkconfig: 35 85 15 # description: Apache server. chmod +x /etc/init.d/httpd /sbin/chkconfig --add httpd /sbin/chkconfig --list httpd ln -s /sbin/chkconfig /usr/bin/chkconfig ln -s /sbin/service /usr/bin/service
原文地址:http://xiochen.blog.51cto.com/2468288/1671388