安裝的背景就是公司項目要用,本身在linux安裝軟件很少,過程比較曲折,須要記錄一下(最近幾篇博客好像都會有這種高大上的背景)~先說下筆者安裝環境以及相關軟件版本:php
操做系統:RedHat Enterprise Linux Server release 5.8 (Tikanga)html
apache:httpd-2.4.25.tar.gzjava
apr:apr-1.5.2.tar.gzlinux
apr-util:apr-util-1.5.4.tar.gzc++
pcre:pcre-8.40.tar.gzapache
下載Apache安裝包(本文下載httpd-2.4.25.tar.gz),下載地址:http://httpd.apache.org/
在安裝Apache時,原做者分別針對不一樣版本進行了安裝,在編譯時是不一樣的,configure後跟的參數不一樣,本文是針對httpd-2.4.25.tar.gz進行安裝網站
httpd-2.4.25版本編譯命令:spa
./configure --prefix=/usr/local/apache2 (安裝目錄參數後面能夠不加任何參數,直接安裝便可) make make install
httpd-2.4.25版本編譯命令:操作系統
./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre (除了指定Apache的安裝目錄外,還要安裝apr、apr-util、pcre,並指定參數) make make install
在編譯Apache(在安裝httpd-2.4.25時遇到的問題)時分別出現了error:apr not found、error:APR-util not found、error:pcre-config for libpcre not found的問題。 .net
下面就httpd-2.4.25的這些問題解決來實際操做一把:
http://apr.apache.org/download.cgi 下載apr-1.5.2.tar.gz、apr-util-1.5.4.tar.gz
https://sourceforge.net/projects/pcre/files/ 下載pcre-8.40.tar.gz(不要下載pcre2開頭的,否則安裝的時候會報找不到pcre-config腳本的錯誤)
1.解決apr not found問題
[root@localhost bin]# tar -zxf apr-1.5.2.tar.gz [root@localhost apr-1.5.2]# ./configure --prefix=/usr/local/apr [root@localhost apr-1.5.2]# make [root@localhost apr-1.5.2]# make install
2.解決APR-util not found問題
[root@localhost bin]# tar -zxf apr-util-1.5.4.tar.gz [root@localhost apr-util-1.5.4]# ./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr/bin/apr-1-config [root@localhost apr-util-1.5.4]# make [root@localhost apr-util-1.5.4]# make install
三、解決pcre-config for libpcre not found問題
[root@localhost ~]# tar -zxf pcre-8.40.tar.gz [root@localhost ~]# cd pcre-8.40 [root@localhost pcre-8.40]# ./configure --prefix=/usr/local/pcre [root@localhost pcre-8.40]# make
[root@localhost pcre-8.40]# make install
若是在安裝pcre過程當中報:
那麼請先執行:
yum install -y gcc gcc-c++
apache默認佔用80端口,因此若是有應用佔用80這個端口,就要注意會存在端口衝突問題。
•啓動Apache:/usr/local/apache2/bin/apachectl start
•中止Apache:/usr/local/apache2/bin/apachectl stop
•重啓Apache:/usr/local/apache2/bin/apachectl restart
在IE中經過http://localhost:80,若是看到頁面中顯示「It works!」字樣,則表明Apache驗證經過。若是網站的index後綴是PHP格式的,則要修改httpd.conf配置文件(/usr/local/apache2/conf),在DirectoryIndex增長 index.php
******************************補充說明*****************************
筆者安裝完APR、ARP-UTIL、PCRE以後,執行以下命令:
./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre
以後,會報以下錯誤:
查來查去,發現貌似是系統自帶的SSL有問題,由於這次安裝使用到的軟件基本都是最新版的,是由於系統自帶的這個openssl版本太低?抱着試一下的態度,從新下載一個openssl進行安裝(反正裝的雲裏霧裏的),先試試再說,附上安裝教程:
1) https://www.openssl.org/source/下載openssl-1.0.2k.tar.gz
2) #tar -xzf openssl-1.0.2k.tar.gz
3) #cd openssl-1.0.2k
4) openssl-1.0.2k#./config --prefix=/usr/local/openssl
5) openssl-1.0.2k#make depend
6) openssl-1.0.2k#cd /usr/local
7) /usr/local# ln -s openssl ssl
8) 在/etc/ld.so.conf文件的最後面,添加以下內容:
/usr/local/openssl/lib
9) # ldconfig
10) 添加OPESSL的環境變量,在/etc/profile的最後一行,添加:
export OPENSSL=/usr/local/openssl/bin
export PATH=$OPENSSL:$PATH:$HOME/bin
11) 執行source /etc/profile
至此,openssl安裝完畢,最後執行:
./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre
apache安裝完畢!
一、http://blog.csdn.net/dazhi_100/article/details/17143213
二、http://www.cnblogs.com/zhuque/archive/2012/11/03/2763352.html