Linux下編譯,安裝Apache httpd伺服器,apachehttpd

來源:互聯網
上載者:User

Linux下編譯,安裝Apache httpd伺服器,apachehttpd

  環境:ubuntu 16.0.4

  Apache官網下載Apache httpd壓縮包:httpd-2.4.27.tar.gz,安裝之前請確定安裝了make工具,我安裝的是GNU make

    安裝 APR(其實不用安裝,後面說明):下載 apr-1.6.2.tar.gz

    解壓:

sudo tar -zxvf '/home/fanchao/案頭/share/apache http server/apr-1.6.2.tar.gz' -C /etc/httpd

     編譯和安裝:

sudo
cd /etc/httpd/apr-1.6.2 #進入解壓後的檔案目錄sudo ./configure #這裡可以添加參數 --prefix=你要安裝的目錄,我這裡沒有加,預設安裝在/user/loacl目錄下 以下所有的./configure都可以添加這個參數sudo makesudo make install

    安裝APR-UTIL(其實不用安裝,後面說明):下載 apr-util-1.6.0.tar.gz

    解壓:

sudo tar -zxvf '/home/fanchao/ 案頭/share/apache http server/apr-util-1.6.0.tar.gz'  -C /etc/httpd

    編譯和安裝

cd /etc/httpd/apr-util-1.6.0sudo ./configure --with-apr=/usr/local/apr/bin/apr-1-configsudo make

    這裡報錯

xml/apr_xml.c:35:19: fatal error: expat.h: 沒有那個檔案或目錄compilation terminated./etc/httpd/apr-util-1.6.0/build/rules.mk:206: recipe for target 'xml/apr_xml.lo' failedmake[1]: *** [xml/apr_xml.lo] Error 1make[1]: Leaving directory '/etc/httpd/apr-util-1.6.0'/etc/httpd/apr-util-1.6.0/build/rules.mk:118: recipe for target 'all-recursive' failedmake: *** [all-recursive] Error 1

    解決辦法就是安裝libexpat1-dev

sudo apt-get install libexpat1-dev

    重新輸

sudo makesudo make install

     安裝httpd所需要的prce庫:下載prce-8.41.zip

     解壓:

sudo unzip   '/home/fanchao/案頭/share/apache http server/pcre-8.41.zip' -d /etc/httpd

    編譯和安裝:

cd /etc/httpd/pcre-8.41sudo ./configuresudo make sudo make install

    最後編譯安裝apache httpd

sudo ./configure --with-apr='/usr/local/apr/bin/apr-1-config' --with-apr-util='/usr/local/apr/bin/apu-1-config' --with-prce='/usr/local/bin/pcre-config' #這裡還有其他參數可以配置,具體參照官方sudo makesudo make install

    到現在按照官方文檔的說明應該就已經安裝好了,但是我到make這步就報錯了

collect2: error: ld returned 1 exit statusMakefile:48: recipe for target 'htpasswd' failedmake[2]: *** [htpasswd] Error 1make[2]: Leaving directory '/etc/httpd-2.4.27/support'/etc/httpd-2.4.27/build/rules.mk:75: recipe for target 'all-recursive' failedmake[1]: *** [all-recursive] Error 1make[1]: Leaving directory '/etc/httpd-2.4.27/support'/etc/httpd-2.4.27/build/rules.mk:75: recipe for target 'all-recursive' failedmake: *** [all-recursive] Error 1

    我查了很多地方都沒有遇到這個錯誤或者說這個錯誤是怎麼發生的。這個錯誤是因為在httpd目錄下的srclib目錄裡面沒有apr和apr-util所導致的,但是./configure又不會報錯,到make才會報錯,所以把下載下來到apr和apr-util解壓到srclib目錄下到apr和apr-util目錄,注意目錄名字要一致。

    這就是我之前說的不用安裝apr和apr-util的原因,它會自動安裝,手動安裝後去指定安裝路徑是會報錯的。

    重建make檔案和make

 sudo ./configure  --with-prce='/usr/local/bin/pcre-config' --with-included-apr #其他參數請參照官方sudo makesudo make install

    現在就可以安裝成功了,如果沒有指定檔案夾那麼就會預設安裝在 /usr/local/apache2

    運行

sudo '/usr/local/apache2/bin/apachectl' -k start #啟動sudo '/usr/local/apache2/bin/apachectl' -k stop #停止

    完結。

 

 

    

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.