LAMP 之二 Apache 安編譯安裝

來源:互聯網
上載者:User

標籤:apache 編譯安裝

 Apache 安裝先去官網上下載安裝包/usr/local/src/,版本不要太新,也不要太舊。

  http://mirrors.cnnic.cn/apache/httpd/

下載之後解壓

[[email protected] src]# wget http://mirrors.cnnic.cn/apache/httpd/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] src]# vim INSTALL


For complete installation documentation, see [ht]docs/manual/install.html or

  http://httpd.apache.org/docs/2.2/install.html


     $ ./configure --prefix=PREFIX

     $ make

     $ make install

     $ PREFIX/bin/apachectl start

#######################################################################################

因為我是看的視頻有現成的步驟(直接拷貝編譯文檔)

[[email protected] httpd-2.2.31]# ./configure \

> --prefix=/usr/local/apache2 \   #指定安裝的目錄

> --with-included-apr \        #apr 是httpd 依賴的一個包(底層的包,支援Apache跨平台運行)

> --enable-so \

> --enable-deflate=shared \    #deflate 支援壓縮的    shared 表示動態支援,下同

> --enable-expires=shared \    #expires支援靜態檔案到期的一些操作

> --enable-rewrite=shared \ #rewrite 網域名稱重新導向,偽靜態。

> --with-pcre                #pcre 是否支援Regex。

這個過程中如果有出現錯誤,請根據報錯提示,解決問題

配置完成後   

[[email protected] httpd-2.2.31]# echo $?

0

輸出“0”表示沒有問題。接著下一步 make,但是我在安裝過程中出現了一個小問題

checking for zlib location... not found

checking whether to enable mod_deflate... configure: error: mod_deflate has been requested but can not be built due to prerequisite failures

[[email protected] httpd-2.2.31]# echo $?

1

上網尋找解決辦法,有網友遇到類似問題

http://blog.csdn.net/xinhaozheng/article/details/4221525

似乎是沒有安裝zlib引起的,而似乎mod_deflate模組又是有依賴於zlib

[[email protected] httpd-2.2.31]# yum install zlib-devel

安裝後,再次編譯

[[email protected] httpd-2.2.31]# echo $?

0

問題解決。下一步make



[[email protected] httpd-2.2.31]# make

make 這個過程在約2分鐘,完成以後

[[email protected] httpd-2.2.31]# echo $?            #檢查有沒有問題

0

接下來:

[[email protected] httpd-2.2.31]# make install


每一步操作完成後建議 

[[email protected] httpd-2.2.31]# echo $?            #檢查有沒有問題

0

至此Apache 安裝完成

###########################################################################################


啟動Apache 

 [[email protected] httpd-2.2.31]# /usr/local/apache2/bin/apachectl start


[[email protected] httpd-2.2.31]# ls /usr/local/apache2/modules/

httpd.exp  mod_deflate.so  mod_expires.so  mod_rewrite.so

mod_deflate.so  mod_expires.so  mod_rewrite.so 這三個模組

這三個模組,都是在編譯選項中加了這三個

[[email protected] httpd-2.2.31]# ls -l /usr/local/apache2/bin/httpd

-rwxr-xr-x 1 root root 2262241 Sep 20 09:41 /usr/local/apache2/bin/httpd

如果在編譯裡不加 shared(動態)  這個三個塊就會和httpd 和在一起,會使得httpd 這個檔案變大。

動態shared 會把這些檔案單獨拿出來產生塊檔案和httpd 分開。

靜態staic 會把檔案彙總在一起,用不用都會載入。耗費資源。


l./configure --prefix=/usr/local/apache2--with-included-apr --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared  --with-pcre

################################################

列出所有的模組

[[email protected] httpd-2.2.31]# /usr/local/apache2/bin/apachectl -M   查看動態載入的模組


[[email protected] httpd-2.2.31]# /usr/local/apache2/bin/apachectl -l   查看靜態載入的模組


/usr/local/apache2/bin/apachectl restrat :(把進程先殺掉再重新開啟新的進程)

        /usr/local/apache2/bin/apachectl stop :(關閉進程)

        /usr/local/apache2/bin/apachectl graceful :(舊進程還在,只是重新載入了設定檔)


[[email protected] httpd-2.2.31]# /usr/local/apache2/bin/apachectl -t  查看設定檔有沒有語法錯誤

httpd: apr_sockaddr_info_get() failed for OBird

httpd: Could not reliably determine the server‘s fully qualified domain name, using 127.0.0.1 for ServerName

Syntax OK

650) this.width=650;" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />

[[email protected] httpd-2.2.31]# ls /usr/local/apache2/conf/httpd.conf  設定檔路徑

/usr/local/apache2/conf/httpd.conf


[[email protected] httpd-2.2.31]# ./configure --help |less  查看協助

指定工作模式

--with-mpm=MPM          Choose the process model for Apache to use.

                          MPM={beos|event|worker|prefork|mpmt_os2|winnt}

worker|prefork  這兩種是我們常用的工作模式

2.4 的版本不指定的,黙認的是 event 模式

2.2 的版本不指定的,黙認的是 prefork 模式


本文出自 “CBO#Boy_Linux之路” 部落格,請務必保留此出處http://20151213start.blog.51cto.com/9472657/1854518

LAMP 之二 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.