centos6.5-搭建Apache
准备工作
1.关闭防火墙
service iptables stop
2.关闭selinux安全机制
setenforce 0
3.卸载rpm格式的httpd
这说明已经安装了rpm格式的软件包。所以要卸载它。
4.卸载
rpm -e httpd –nodeps
二、安装httpd
1、下载apache
wget http://archive.apache.org/dist/httpd/httpd-2.2.17.tar.gz
2、解压压缩包
tar xf httpd-2.2.17.tar.gz –C /usr/src
3、编译源码包,并且安装
(1)cd httpd-2.2.17
./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi
编译完成后,如上图,说明已经编译成功
如果出现以下错误
则在编译时入加 --with-included-apr 即可解决。
优化路径
ln -s /usr/local/httpd/bin/* /usr/local/bin/
cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
4. vi /etc/init.d/httpd #编辑启动脚本,增加红色部分内容
#!/bin/sh
#chkconfig:345 66 88
#description:http apache
解释:
345 66 88表示:345运行级别是开启的,66为服务启动顺序,88服务为停止顺序。
(4)chmod +x /etc/init.d/httpd
chkconfig --add httpd
chkconfig --list httpd
5、启动服务
service httpd start
报错1:httpd: Could not reliably determine the server's fully qualified domain name, using ::1 for ServerName
解决:vim /usr/local/httpd/conf/httpd.conf
97 #ServerName www.example.com:80
98 ServerName localhost:80