centos 7 經過源碼安裝apache

一: 1.源碼安裝方式:源碼安裝的好處是用戶能夠定製軟件功能,安裝須要的模塊,不須要的功能能夠不用安裝,也能夠選擇安裝路徑,
卸載軟件也方便,只須要刪除對應的安裝目錄便可。
2.源碼方式編譯安裝過程:
a.源碼安裝軟件通常有如下幾個步驟組成: 下載解壓源碼、分析安裝平臺環境(configure)、編譯安裝軟件(make 、make install)linux

configure文件通常是個可執行文件,能夠在當前目錄下直接輸入「./configure」進行軟件安裝的環境測試,若是提示缺乏某些安裝包,就須要進行安裝,直到測試經過。一般的,
        源碼安裝都須要GCC或者CC編譯器,這些編譯器通常在安裝系統時定製安裝包中的開發工具選項下。

        make是常常用的編譯命令,對於一個包含不少源文件的應用程序,使用make和makefile工具能夠簡單快速的解決各個源文件之間複雜的依賴關係。
      3. 源碼包安裝注意事項:   經過源碼方式安裝軟件,須要把開發工具等基礎模塊安裝號,好比 gcc、gcc-c++、libgcc、glibc、make、automake等開發工具或基礎包;還要安裝
                                            一些相應的開發包,通常是文件名包括dev的,好比glibc-devel、gettext-devel;還有一些開發庫,好比以lib開頭的開發庫。

              源代碼通常以 file.tar.gz  file.tar.bz2打包,file.tar.gz和file.tar.bz2格式的解包命令以下:
                 #tar  jxvf  file.tar.bz2  ;    #  tar  zxvf  file.tar.gz  解壓後可發現  README或readme和INSTALL或install,這些都是安裝說明;
              configure比較重要的一個參數是 --prefix,用 --prefix參數,咱們能夠指定軟件安裝目錄,當不須要這個軟件時,直接刪除軟件安裝目錄便可。
               #more /etc/redhat-release   (查看linux系統版本)

4.源碼安裝Apache HTTp server :
1.下載http server :# wget https://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.46.tar.gz
2.解壓 : # tar zxvf httpd-2.4.46.tar.gz
3.進入源碼包 : # cd httpd-2.4.46
4.查看說明文件 : INSTALL 或者 README
5.# ./configure --prefix=/usr/local/apache2 (指定安裝到 目錄/usr/local/apache2 下) --enable-so --enable-mods-shared=most --enable-proxy-http=shared --enable-rewritec++

報錯: checking for ARP...no
configure:error:ARP not found.please read...
解決方法:1.在apr官網: https://apr.apache.org下載: apr 1.7.0和apr-util 1.6.1; apache

wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.7.0.tar.gz (下載apr)

#wget   https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.gz  (下載 apr-util)
               解壓:
                #tar  zxvf apr-1.7.0.tar.gz
                 #cd  apr-1.7.0
                 # ./configure --prefix=/usr/local/apr
                 #make   (編譯)
                 # make install  (執行安裝操做)
               完成 apr-1.7.0的安裝
                解壓  apr-util-1.6.1
                #tar  zxvf apr-util-1.6.1.tar.gz  
                # ./configure  --prefix=/usr/local/apr-util  --with-apr=/usr/local/apr   (執行./configure,進行環境測試)
                # make  (執行編譯)  報錯:fatal error:  expat.h: no such file.... make:***[all-recursive]  Error 1
                 上面錯誤是由於缺乏某個包或者庫文件,多是expat.h文件沒有安裝。解決: #yum install expat (不可行)   # yum install expat-devel   (錯誤排除)
                # make  install

解決完錯誤繼續安裝apache
依然報錯: configure: error:APR-util not found .
解決: # ./configure --prefix=/usr/local/apache2 --enable-so --enable-mods-shared=most --enable-proxy-http=shared --enable-rewrite --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
依然報錯: configure: error : pcre-config for libpcre not found. (說明pcre還沒安裝)
解決: 在pcre官網: www.pcre.org 下載pcre : #wget https://ftp.pcre.org/pub/pcre/pcre-8.40.tar.gz
解壓pcre : # tar zxvf pcre-8.40.tar.gz 進入pcre目錄 :# cd pcre-8.40 #./configure --prefix=/usr/local/pcre (環境監測)app

make (編譯) #make install (安裝pcre) (#yum -y install gcc-c++ (安裝c++) )

6.  繼續安裝apache :#./configure  --prefix=/usr/local/apache2  --enable-so  --enable-mods-shared=most  --enable-proxy-http=shared  --enable-rewrite  --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util  --with-pcre=/usr/local/pcre
          7.執行make報錯: collect2:error:ld returned 1 exit status  解決:在app 目錄下  #cp -r  apr-1.7.0 httpd-2.4.46/srclib/apr   #cp -r apr-util-1.6.1 httpd-2.4.46/srclib/apr-util
          繼續報錯:解決 #./configure  --prefix=/usr/local/apache2  --enable-so  --enable-mods-shared=most  --enable-proxy-http=shared  --enable-rewrite  --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util  --with-pcre=/usr/local/pcre  --with-included-apr

         8.# make  (編譯)
         9.# make install (安裝)

無報錯,完成安裝。 驗證安裝是否正確: 進入安裝目錄: # cd /usr/local/apache2/ #cd /bin #./httpd -V (查看httpd的編譯環境和版本)ide

相關文章
相關標籤/搜索