Apache HTTP Server安装

1. 需要的安装包

安装Apache HTTP Server,搭建环境需要pcreaprapr-utilgcc依赖,安装apr-util依赖expat;所以需要安装以下几个环境。

expat_2.0.1.orig.tar.gz https://launchpad.net/ubuntu/+source/expat/2.0.1-7.2ubuntu1.4
apr-1.7.0.tar.gz http://apr.apache.org/download.cgi
apr-util-1.6.1.tar.gz http://apr.apache.org/download.cgi
pcre-8.42.tar.gz https://ftp.pcre.org/pub/pcre/
httpd-2.4.39.tar.gz http://httpd.apache.org/download.cgi#apache24

2.安装

2.1 安装gcc

  • yum install gcc gcc-c++; ubuntu: sudo apt-get install build-essential
  • 版本查看gcc --version g++ --version

2.2. 安装expat

tar -zxvf expat_2.0.1.orig.tar.gz
./configure --prefix=/home/zhanhao/software/expat
make
make install

2.3 安装apr

tar -zxvf apr-1.7.0.tar.gz
./configure --prefix=/home/zhanhao/software/apr/
make
make install

2.4 安装apr-util

tar -zxvf apr-util-1.6.1.tar.gz
./configure --prefix=/home/zhanhao/software/apr-util --with-apr=/home/zhanhao/software/apr --with-expat=/home/zhanhao/software/expat
make
make install

2.5 安装pcre

tar -zxvf pcre-8.42.tar.gz
./configure --prefix=/home/zhanhao/software/pcre
make
make install

2.6 安装httpd

tar -zxvf httpd-2.4.39.tar.gz
./configure --prefix=/home/zhanhao/software/apache --with-apr=/home/zhanhao/software/apr --with-apr-util=/home/zhanhao/software/apr-util --with-pcre=/home/zhanhao/software/pcre
make
make install

make的时候错误提示:cannot find the library libapr-1.la or unhandled argument libapr-1.la
apr-util 需要依赖apr,在apr-util的lib目录下的la文件中将对apr库的依赖路径修改一下

vi /home/zhanhao/software/apr-util/lib/libaprutil-1.la

3. 修改配置

  • cd /home/zhanhao/software/apache/conf
  • vi apachectl
  • 修改 Listen 80 端口,80只有root才能使用,我的是9010
  • 若启动的时候提示报错: (92)Protocol not available: AH00076: Failed to enable APR_TCP_DEFER_ACCEPT
    apachectl文件的最后一行添加 AcceptFilter http none

4. 启动

  • cd /home/zhanhao/software/apache/bin
  • ./apachectl
  • 访问localhost:9010 看见 It works! 就ok了。

你可能感兴趣的:(Apache HTTP Server安装)