centos7源碼安裝apache


轉載:https://www.cnblogs.com/yehuisir/articles/10061123.html

擴展內容:https://blog.51cto.com/chenhao6/1223484

原文內容做補充

 

安裝軟件:
a. httpd官方網站/下載地址:

http://httpd.apache.org/download.cgi 或 https://github.com/dollarphper/soft/raw/master/apache/httpd-2.4.34.tar.gz

b. arp、arp-util官方網站:

http://apr.apache.org/download.cgi 或 https://github.com/dollarphper/soft/raw/master/apache/apr-1.6.3.tar.gz https://github.com/dollarphper/soft/raw/master/apache/apr-util-1.6.1.tar.gz

c. pcre官方網站:

https://www.pcre.org/ 或 https://github.com/dollarphper/soft/raw/master/apache/pcre-8.42.tar.gz

d.安裝需要的依賴包:

 gcc  expat-devel  openssl-devel pcre pcre-devel  libxm12-devel

 

1.先進入/usr/local/中創建三個文件夾 apr apr-util apache

  

 

 

 

2.解壓源碼包

   

 

 

 

3.安裝依賴包,文章開頭已經指出需要安裝的依賴包。

  

 

 

 

4.編譯安裝apr,需要進入apr-1.6.3 目錄中編譯

  

 

 

 

5.編譯安裝apr-util

  

 

 

 

6.編譯安裝apache  

cd httpd-2.4.37

./configure \
--prefix=/usr/local/apache/ \
--with-apr=/usr/local/apr/ \
--with-apr-util=/usr/local/apr-util/ \
--enable-so \
--enable-ssl\
--enable-deflate=shared \
--enable-expires=shared \
--enable-rewrite=shared \
--enable-static-support

檢查無誤,然后開始編譯安裝

make && make install

 

7.安裝完成,開啟apache服務

  

 

 

   

 

 

     啟動apache服務報錯,解決辦法:vim /usr/local/apache/conf/httpd.conf

    #增加

    ServerName wx.xxxx.club (就是增加域名)

 

        

 

 

       再次啟動服務:  ./apachectl start

 

8.  

  

 

 

 

  當輸入域名時顯示it works! ,就表示apache源碼安裝就此完成,

  記住 想要重啟apache 必須切換到 

  cd /usr/local/apache/bin/ 目錄

  使用 

  ./apachectl start 開啟apache 

  ./apachectl restart 重啟apache 

  ./apachectl configtest  檢測apache配置文件語法是否正確  

 8.使程序可以使用service管理

   

 

 

  

 

   再文件最前面插入行,使其支持chkconfig命令

    #!/bin/sh 

              # chkconfig: 2345 85 15 

              # description: Apache is a World Wide Web server.

 

  chmod  +x  /etc/init.d/httpd  #執行權限

 

  chkconfig --add httpd 

  

  

 

 

 

 

 




免責聲明!

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



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