1. 需要的安裝包
安裝Apache HTTP Server薛耻,搭建環(huán)境需要pcre
输钩、apr
豺型、apr-util
、gcc
依賴买乃,安裝apr-util
依賴expat
姻氨;所以需要安裝以下幾個環(huán)境。
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了功戚。