LAMP--2.Apache 編譯安裝

來源:互聯網
上載者:User

標籤:apache   安裝   編譯   

         apache 官網:http://www.apache.org/dyn/closer.cgi 。建議使用國內開源鏡像地址:http://mirrors.aliyun.com/apache/httpd/httpd-2.2.31.tar.bz2  或 http://mirrors.sohu.com/apache/httpd-2.2.31.tar.bz2 。所謂的apache,真正的名字是 httpd。

     

         下載

[[email protected] ~]# cd /usr/local/src[[email protected] src]# wget http://mirrors.sohu.com/apache/httpd-2.2.31.tar.bz2

         解壓

[[email protected] src]# tar jxvf httpd-2.2.31.tar.bz2

         配置編譯參數

[[email protected] src]# cd httpd-2.2.31[[email protected] httpd-2.2.31]#  ./configure  --prefix=/usr/local/apache2  --with-included-apr  --enable-so  --enable-deflate=shared  --enable-expires=shared  --enable-rewrite=shared  --with-pcre

        --prefix 指定安裝到哪裡, --enable-so表示啟用DSO,--enable-deflate=shared表示動態共用的方式編譯deflate模組,後面的參數同理。既然有動態那當然也有靜態了,這兩者有什麼區別呢?apache 編譯安裝完成後會產生一個核心的二進位可執行檔叫做 httpd,這個檔案作為核心檔案,提供服務時就是它在處理使用者的請求,但是有些功能,比如這裡提到的expires就是配置靜態檔案(圖片)到期時間的,也就是說圖片可以在使用者瀏覽器的臨時緩衝目錄中緩衝多久。這些功能是作為 httpd 的一個擴充模組來工作的,那麼這種擴充模組有兩種存在的方式,一種是直接在編譯的時候和 httpd 檔案結合在一起,組成一個體積大的檔案,這種方式就叫做靜態。而另外一種方式是,擴充模組作為一個獨立的檔案存在,只有在使用這個模組時再去調用它,這種方式就是動態共用。其中,動態好處是,核心檔案 httpd 比較小,模組隨時用隨時載入,耗費記憶體相對較少。而靜態優勢是,在服務啟動時,會把所有模組載入,到用時很快就執行,效率較高。

        ./configure 這一步經常會出現錯誤:

 error: mod_deflate has been requested but can not be built due to prerequisite failures[[email protected] httpd-2.2.31]# yum install -y zlib-devel

        為了避免在 make 的時候出現錯誤,最好是提前先安裝好一些庫檔案:

#yum install -y pcre pcre-devel apr apr-devel

         編譯和安裝

#make

#make install

[[email protected] httpd-2.2.31]# makemake[4]: Leaving directory `/usr/local/src/httpd-2.2.31/modules/mappers‘make[3]: Leaving directory `/usr/local/src/httpd-2.2.31/modules/mappers‘make[2]: Leaving directory `/usr/local/src/httpd-2.2.31/modules‘make[2]: Entering directory `/usr/local/src/httpd-2.2.31/support‘make[2]: Leaving directory `/usr/local/src/httpd-2.2.31/support‘make[1]: Leaving directory `/usr/local/src/httpd-2.2.31‘[[email protected] httpd-2.2.31]# echo $?0[[email protected] httpd-2.2.31]# make installmake[2]: Entering directory `/usr/local/src/httpd-2.2.31/support‘make[2]: Leaving directory `/usr/local/src/httpd-2.2.31/support‘Installing configuration files[PRESERVING EXISTING HTDOCS SUBDIR: /usr/local/apache2/htdocs][PRESERVING EXISTING ERROR SUBDIR: /usr/local/apache2/error][PRESERVING EXISTING ICONS SUBDIR: /usr/local/apache2/icons][PRESERVING EXISTING CGI SUBDIR: /usr/local/apache2/cgi-bin]Installing header filesInstalling build system filesInstalling man pages and online manualmake[1]: Leaving directory `/usr/local/src/httpd-2.2.31‘[[email protected] httpd-2.2.31]# echo $?0


    apache 啟動指令碼加入系統服務列表

[[email protected] php-5.6.10]# cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd[[email protected] php-5.6.10]# vim /etc/init.d/httpd

    在第一行#!/bin/sh 下面添加兩行文字

#chkconfig: 35 70 30#description: Apache

    儲存退出

[[email protected] php-5.6.10]# chkconfig --add httpd[[email protected] php-5.6.10]# chkconfig --level 35 httpd on



本文出自 “散宜生的學習筆記” 部落格,請務必保留此出處http://sanyisheng.blog.51cto.com/11154168/1795790

LAMP--2.Apache 編譯安裝

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.