1.下載Apache2.4.9 http://httpd.apache.org/download.cgi html
2.tar httpd-2.4.9壓縮包
tar -zxvf httpd-2.4.9 apache
3.進入httpd-2.4.9文件夾
cd httpd-2.4.9 vim
4.下載apr-1.5.1.tar.gz http://apr.apache.org/download.cgi
若是有apr能夠跳過此步驟
tar apr-1.5.1.tar.gz
複製apr文件夾到 /usr/local/apache下
cp -vRp /home/sniper/Downloads/apr-1.5.1 /usr/local/apache
進入apr文件夾
cd apr
編譯
./configure
安裝
make & make install 瀏覽器
5.下載apr-util-1.5.3.gz http://apr.apache.org/download.cgi
tar apr-util-1.5.3.gz
複製到/usr/local/apache下
cp -vRp /home/sniper/Downloads/apr-util-1.5.3 /usr/local/apache
重命名
mv /usr/local/apache/apr-util-1.5.3 /usr/local/apache/apr-util
進入apr-util文件夾下
cd /usr/local/apache/apr-util
編譯
./configure --with-apr=/usr/local/apache/apr
安裝
make & make install 測試
6.下載pcre-config http://pcre.org
tar pcre-8.3.5
mv 到 /usr/local/apache
cd /usr/local/apache/pcre-8.3.5
./configure
make & make install rest
7.從新安裝apr-util htm
8.進入httpd目錄
cd /home/sniper/httpd ip
9.編譯
./configure --prefix=/usr/local/apache
make & make install it
10.啓動apache
bin/apachectl start
若是出現 /usr/local/apache/bin/httpd: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
的錯誤,輸入
sudo ldconfig
從新啓動服務
若是出現
/usr/local/apache/bin/httpd: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory錯誤
打開配置文件 vim /usr/local/apache/conf/httpd.conf
找到 #ServerName www.example.com:80 把 # 註釋去掉,重啓
重啓命令:bin/apachectl restart 編譯
11.添加測試文件 /usr/local/apache/htdocs/test.html hello world !
12.瀏覽器中輸入 http://localhost/test.html
13.關閉apache bin/apachectl stop