前期準備:
Redhat Enterprise Linux 6.0 x86_64、 apache:httpd-2.4.25.tar.gz、 apr:apr-1.5.2.tar.gz、 apr-util:apr-util-1.5.4.tar.gz、 pcre:pcre-8.40.tar.gz、 expat-devel、 gcc gcc-c++
一、基礎環境配置
yum install -y gcc gcc-c++ yum install expat-devel
二、apr、apr-util、pcre、Apache安裝
http://apr.apache.org/download.cgi 下載apr-1.6.5.tar.gz、apr-util-1.6.1.tar.gz
https://sourceforge.net/projects/pcre/files/ 下載pcre-8.42.tar.gz(不要下載pcre2開頭的,不然安裝的時候會報找不到pcre-config腳本的錯誤)
http://httpd.apache.org/ 下載httpd-2.4.37.tar.gz
(1)apr安裝
#tar -zxf apr-1.6.5.tar.gz #./configure --prefix=/usr/local/apr #make #make install
(2)apr-util
#tar -zxf apr-util-1.6.1.tar.gz #./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr/bin/apr-1-config #make #make install
(3)pcre安裝
#tar -zxf pcre-8.42.tar.gz #./configure --prefix=/usr/local/pcre #make #make install
(4)Apache安裝
#tar -zxf httpd-2.4.37.tar.gz #./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre #make #make install
*補充說明
在安裝httpd-2.4.37時報錯:
error:apr not found、error:APR-util not found、error:pcre-config for libpcre not found
原 因:
未安裝apr、apr-util、pcre或安裝錯誤
解決方法:
重新安裝apr、apr-util、pcre
在安裝apr-util-1.6.1時報錯:
make[1]: *** [xml/apr_xml.lo] Error 1 make[1]: Leaving directory `/apr-util-1.6.1' make: *** [all-recursive] Error 1
原 因:
缺少expat庫
解決方法:
yum install expat-devel
在安裝pcre-8.42時報錯:
configure: error: You need a C++ compiler for C++ support
原 因:
沒有安裝對應的gcc 和gcc-c++
解決方法:
yum install -y gcc gcc-c++
在安裝httpd-2.4.37時報錯:
make[2]:?[htpasswd] 錯誤 1 make[2]: 離開目錄“/usr/local/src/httpd-2.4.27/support” make[1]:?[all-recursive] 錯誤 1 make[1]: 離開目錄“/usr/local/src/httpd-2.4.27/support” make: *** [all-recursive] 錯誤 1
解決方法:
複製apr、apr-util、pcre至httpd-2.4.27/srclib下進行安裝
建議:安裝程序時建議make和make install分開運行。
apache默認佔用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
參考鏈接:
https://www.cnblogs.com/xdouby/p/6406873.html
https://blog.csdn.net/qq_41772936/article/details/80878635