1.下载apache,最新版的2.4.12 ------------http://httpd.apache.org/download.cgi
2.需要下载apr,apr-util,顺便把apr-iconv也给下载了,在这个界面:http://apr.apache.org/download.cgi
3.编译安装pcre,http://pcre.org/ 选的8.36,刚开始选了最新版的pcre2,编译apache时候,提示找不到pcre-config,pcre2里面的是pcre2-config
4.解压后开始编译apache2, ./configure --prefix=/usr/local/httpd --with-apr=APR编译的路径 --with-apr-util=APR-UTIL编译的路径 --with-pcre=PCRE编译的路径
5.完成后 修改配置文件httpd.conf 修改ServerName 为 localhost
6.
#cp /usr/local/httpd/bin/apachectl /etc/rc.d/init.d/httpd
7.
#systemctl start httpd.service
#ps -ef|grep httpd检测是否启动
8.设置开机启动,这里遇见问题:
#systemctl enable httpd.service
httpd.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig httpd on
service httpd does not support chkconfig
找了好久,才找到了解决方法:
<div><span style="color:#2c2c2c;background-color: rgb(255, 255, 255); line-height: 28px;">打开</span> <span style="font-family:宋体, 'Arial narrow', arial, serif;color:#2c2c2c;background-color: rgb(255, 255, 255); line-height: 28px;">vi /etc/rc.d/init.d/httpd 添加(#!/bin/sh下面)</span></div><p style="padding: 0px 0px 15px; margin: 0px;">#chkconfig: 2345 1090<br style="padding: 0px; margin: 0px;" />#description: Activates/Deactivates Apache Web Server</p><p style="padding: 0px 0px 15px; margin: 0px;">加上上面这两行就可以,#必须有</p><p style="padding: 0px 0px 15px; margin: 0px;">其中:2345是设为要启动的运行级别,10是启动优先级,90是杀死进程的优先级,谁优先谁先挂的意思。</p>(感谢:http://blog.sina.com.cn/s/blog_5d15305b0101ceft.html)
apache的error_log里还有两行:
[Sat May 16 06:48:47.305736 2015] [mpm_event:notice] [pid 495:tid 139674220660544] AH00489: Apache/2.4.12 (Unix) configured -- resuming normal operations
[Sat May 16 06:48:47.305899 2015] [core:notice] [pid 495:tid 139674220660544] AH00094: Command line: '/usr/local/httpd/bin/httpd'
还未解决。