Skip to content

linux(centos5.5)下安装apache2.4.2

自己的网站一直使用的是nginx,没有在linux下安装过apache。最近公司大规模的迁移服务器,和我相关的几个业务的服务器都是apache的,有可能需要自己部署,所以在本机的centos5.5上模拟下真实安装。看网上说apache2.4.2各种优点,最重要的说是更加安全了。我就不翻译来自官网的说明了,给出链接 Apache2.4.2介绍。 好,我们言归正传,开始进行安装,下面就是我安装过程的记录,如果你希望全新安装,希望你能看完整个文档再来安装。在centos下安装apache2.4.2并没有那么难,但整个过程中我还是遇见了几个问题,下面把apache2.4.2在linux下的安装过程分享给大家。

获取apache2.4.2源文件并解压

wget http://apache.etoak.com//httpd/httpd-2.4.2.tar.gz
tar -zxvf httpd-2.4.2.tar.gz
cd httpd-2.4.2
./configure --prefix=/usr/local/apache2 --enable-so --enable-mods-shared=all --enable-vhost-alias --enable-expires --enable-rewrite --enable-authn-dbm=shared

检查过程出现下面错误APR(APACHE PORTABLE RUNTIME)不存在,显示如下

checking for chosen layout... Apache

checking for working mkdir -p... yes

checking for grep that handles long lines and -e... /bin/grep

checking for egrep... /bin/grep -E

checking build system type... i686-pc-linux-gnu

checking host system type... i686-pc-linux-gnu

checking target system type... i686-pc-linux-gnu

Configuring Apache Portable Runtime library ...

checking for APR... no

configure: error: APR not found. Please read the documentation. 安装APR

各个版本的APR下载 http://apr.apache.org/download.cgi 安装APR

wget http://mirror.bjtu.edu.cn/apache//apr/apr-1.4.6.tar.gz
tar -zxvf apr-1.4.6
cd apr-1.4.6
./configure --prefix=/usr/local/apr
make
make install

安装完成后继续之前操作

[root@localhost httpd-2.4.2]# ./configure --prefix=/usr/local/apache2 --enable-so --enable-mods-shared=all --enable-vhost-alias --enable-expires --enable-rewrite --enable-authn-dbm=shared --with-apr=/usr/local/apr

checking for chosen layout... Apache

checking for working mkdir -p... yes

checking for grep that handles long lines and -e... /bin/grep

checking for egrep... /bin/grep -E

checking build system type... i686-pc-linux-gnu

checking host system type... i686-pc-linux-gnu

checking target system type... i686-pc-linux-gnu

Configuring Apache Portable Runtime library ...

checking for APR... yes

setting CC to "gcc"

setting CPP to "gcc -E"

setting CFLAGS to " -g -O2 -pthread"

setting CPPFLAGS to " -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE"

setting LDFLAGS to " "

Configuring Apache Portable Runtime Utility library...

checking for APR-util... no

configure: error: APR-util not found. Please read the documentation. 安装APR-util

wget http://mirror.bjtu.edu.cn/apache//apr/apr-util-1.4.1.tar.gz
tar -zxvf apr-util-1.4.1.tar.gz
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/
make&&make install

安装完成APR-util后继续之前操作

 

[root@localhost httpd-2.4.2]# ./configure --prefix=/usr/local/apache2 --enable-so --enable-mods-shared=all --enable-vhost-alias --enable-expires --enable-rewrite --enable-authn-dbm=shared --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/
make && make install

  安装成功后,

cp /usr/local/http/bin/apachectl /etc/rc.d/init.d/httpd
chmod 755 /etc/rc.d/init.d/httpd
/etc/rc.d/init.d/httpd start

本地使用lynx 127.0.0.1 结果是it works 远程上不行,通过关闭防火墙 service iptables stop 远程就可以访问了 如果不想关闭防火墙,放开80端口即可。

#vi /etc/sysconfig/iptables 增加一行-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT #service iptables restart //重启防火墙 这样就大功告成了。