Linux下編譯安裝Apache報APR not found錯誤的解決辦法


我在編譯安裝完Nginx、MySQL和PHP(見之前一篇博客:LNMP環境搭建詳細教程)之后,進行apache的編譯安裝:
cd /usr/local/src 
wget http:
//mirror.bit.edu.cn/apache/httpd/httpd-2.4.34.tar.gz 
tar zxvf httpd
-2.4.34.tar.gz  
cd httpd
-2.4.34  
.
/configure --prefix=/usr/local/httpd  
就在這個時候提示:configure: error: APR not found. Please read the documentation.
這說明缺少APR依賴,那么安裝即可,可以用yum安裝但是不推薦,因為yum安裝的APR版本可能不足以支持你所安裝的apache版本,所以還是要用編譯安裝高版本的APR:
cd /usr/local/src

wget http://archive.apache.org/dist/apr/apr-1.6.3.tar.gz 

wget http://archive.apache.org/dist/apr/apr-util-1.6.1.tar.gz

依次下載上述兩個安裝包並逐個解壓縮:

tar zxvf apr-1.6.3.tar.gz

tar zxvf apr-util-1.6.1.tar.gz
cd/usr/local/src/apr-1.6.3 #安裝apr

.
/configure --prefix=/usr/local/apr

make && make install
cd /usr/local/src/apr-util-1.6.1  #安裝apr-util

./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

make && make install
依賴全部安裝完畢后再次切換到httpd的安裝目錄安裝apache:
cd /usr/local/src/httpd-2.4.34

./configure --prefix=/usr/local/httpd --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util

make && make install

到此安裝成功,想要啟動、停止、重啟apache需要用到命令:

/usr/local/httpd/bin/httpd -k start   ##開啟
/usr/local/httpd/bin/httpd -k stop ##停止
/usr/local/httpd/bin/httpd -k restart ##重啟

這里我在重啟的時候就報了之前一篇博客:LNMP環境搭建詳細教程中講述的一個錯誤:

bind() to 0.0.0.0:80 failed (98: Address already in use)  這是因為我之前安裝了nginx已經占用了80端口並且正在運行端口發生沖突,

所以就需要修改httpd的端口號,配置文件位置/usr/local/httpd/conf/httpd.conf:

vim /usr/local/httpd/conf/httpd.conf

搜索Listen 80將其改為Listen 8080(修改的端口號可以隨便定義,范圍是0~65535,其中0沒有任何意義,也可以理解為1~65535),重啟httpd提示新的錯誤:Could not reliably determine the server's fully qualified domain name,

這是因為httpd.conf中ServerName未修改,搜索ServerName,將其改為:ServerName localhost:8080之后再次重啟錯誤消失,查看一下正在運行的服務:

 ps:上述安裝的依賴版本並不是固定的,在安裝的時候最好到官網看一下文檔說明,選用高級的版本,比如用apr-1.3.*的版本,用來編譯安裝httpd-2.4.*的apache的時候就編譯不了了


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM