在linux下,使用默認安裝軟件,在開發過程中會經常不知道到什麼路徑下找到所需的程序,
因此手動安裝程序對後續的使用會非常便利。
一,準備
1、安裝 apr
下載地址:http://apr.apache.org/download.cgi
[root@localhost:/work/soft/apache]# tar jxvf apr-1.5.0.tar.bz2
[root@@localhost:/work/soft/apache/apr-1.5.0]# ./configure --prefix=/work/installed/apr
[root@@localhost:/work/soft/apache/apr-1.5.0]# make
[root@@localhost:/work/soft/apache/apr-1.5.0]# make install
2、安裝 apr-util
下載地址:http://apr.apache.org/download.cgi
[root@localhost:/work/soft/apache]# tar jxvf apr-util-1.5.3.tar.bz2
[root@@localhost:/work/soft/apache/apr-util-1.5.3]# ./configure --prefix=/work/installed/apr-util --with-apr=/work/installed/apr
[root@@localhost:/work/soft/apache/apr-util-1.5.3]# make
[root@@localhost:/work/soft/apache/apr-util-1.5.3]# make install
3、安裝 pcre
下載地址:http://pcre.org/
[root@localhost:/work/soft/apache]# tar jxvf pcre-8.35.tar.bz2
[root@@localhost:/work/soft/apache/pcre-8.35]# ./configure --prefix=/work/installed/pcre
[root@@localhost:/work/soft/apache/pcre-8.35]# make
[root@@localhost:/work/soft/apache/pcre-8.35]# make install
注意:如果在安裝 pcre 時,遇到問題:configure: error: You need a C++ compiler for C++ support.
解決方法:sudo apt-get install build-essential
二、安裝apache
下載地址:http://httpd.apache.org/
[root@localhost:/work/soft/apache]# tar jxvf httpd-2.4.9.tar.bz2
[root@@localhost:/work/soft/apache/httpd-2.4.9]# ./configure --prefix=/work/installed/apache --with-apr=/work/installed/apr --with-apr-util=/work/installed/apr-util --with-pcre=/work/installed/pcre
[root@@localhost:/work/soft/apache/httpd-2.4.9]# make
[root@@localhost:/work/soft/apache/httpd-2.4.9]# make install
三、配置
1、修改配置文件,否則會出現問題:
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
解決方法:
[root@localhost:/work/installed/apache]# sudo gedit conf/httpd.conf
把:
# ServerName www.example.com:80
改爲:
ServerName localhost:80
2、啓動
[root@localhost:/work/installed/apache]# ./bin/apachectl start