apache2安装及配置
环境:centos6.5
下载:
wget -c http://mirrors.cnnic.cn/apache//httpd/httpd-2.4.23.tar.gz http://apache.spd.co.il/apr/apr-1.5.2.tar.gz http://apache.spd.co.il/apr/apr-util-1.5.4.tar.gz ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz
解压:
tar -vxf httpd-2.4.23.tar.gz
tar -vxf apr-util-1.5.4.tar.gz
tar -vxf apr-1.5.2.tar.gz
tar -vxf pcre-8.39.tar.gz
进入目录并编译:
#apr
cd apr-1.5.2
./configure --prefix=/usr/local/apr
make &&make install
#apr-util
cd apr-util-1.5.4
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make &&make install
#pcre
cd pcre-8.39
./configure
make &&make install
#apache2
cd httpd-2.4.23
./configure --prefix=/usr/local/apache2 --enable-module=so --enable-ssl=sharedSSL --enable-rewrite=shared --enable-proxy=shared --enable-deflate=shared --with-mpm=worker --enable-expires=shared --enable-speling=shared --enable-mods-shared=all --enable-module=most --enable-mods-shared=all --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
make &&make install
安装apr-util,报‘apr_xml_parser’没有名为‘xp_err’的成员错误时,yum inatsll -y expat-devel即可
服务目录:/usr/local/apache2/bin/apachectl
加入自启动:echo "/usr/local/apache2/bin/apachectl start" >> /etc/rc.local
生成控制脚本:grep -v "#" /usr/local/apache2/bin/apachectl > /etc/init.d/apache
添加chkconfig支持:vim /etc/init.d/apache
#!/bin/sh
# chkconfig: 2345 85 15
# description: Apache is a World Wide Webserver.
修改控制权限:chmod +x /etc/init.d/apache
添加到系统服务:chkconfig --add apache
完成后,使用
#启动apache
service apache start
#关闭apache
service apache stop
添加防火墙例外:
/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
/etc/rc.d/init.d/iptables save
/etc/init.d/iptables restart