Apache HTTPD在Linux上的安装与配置
1.apache httpd与依赖库下载
apache httpd下载地址:
http://httpd.apache.org/
pcre(Perl Compatible Regular Expressions)下载地址:
http://www.pcre.org/
https://sourceforge.net/projects/pcre/files/pcre/
openssl下载地址:
http://www.openssl.org/
apr(Apache Protable Runtime)下载地址:
http://apr.apache.org/
2.安装pcre
# tar zxvf pcre-8.35.tar.gz
# cd pcre-8.35
# ./configure -prefix=/usr/local/pcre
# make
# make install
3.安装apr
# tar zxvf apr-1.5.1.tar.gz
# cd apr-1.5.1
# ./configure -prefix=/usr/local/apr -with-pcre=/usr/local/pcre
# make
# make install
4.安装apr-util
# tar zxvf apr-util-1.5.3.tar.gz
# cd apr-util-1.5.3
# ./configure -prefix=/usr/local/apr-util -with-apr=/usr/local/apr
# make
# make install
5.安装httpd
# tar zxvf httpd-2.4.9.tar.gz
# cd httpd-2.4.9
# ./configure -prefix=/usr/local/httpd -with-pcre=/usr/local/pcre -with-apr-util=/usr/local/apr-util
# make
# make install
或者可以不用单独安装依赖包apr与apr-util,将httpd解压后有个srclib目录,将apr和apr-util的包解压到srclib,去掉版本号。安装httpd时自动安装apr与apr-util。
# tar zxvf httpd-2.4.9.tar.gz
# cd /software/httpd-2.4.9/srclib
# tar -zxvf apr-1.5.1.tar.gz
# tar -zxvf apr-util-1.5.3.tar.gz
# mv apr-1.5.1 apr
# mv apr-util-1.5.3 apr-util
# ./configure -prefix=/usr/local/httpd -with-pcre=/usr/local/pcre
# make
# make install
6.运行apache httpd,默认端口80
启动apache httpd
# cd /usr/local/httpd
# ./httpd -k start
# ./httpd -k restart
测试web服务.
打开防火墙80端口,以使外部网络可以访问
# vi /etc/sysconfig/iptables
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
# service iptables restart
外部网络通过浏览器访问:
http://192.168.16.133
停止apache httpd
# ./httpd -k stop