編譯安裝Apache

來源:互聯網
上載者:User

標籤:apache

1、apache官網: http://www.apache.org/dyn/closer.cgi 

2、進入到目錄、下載源碼包

cd /usr/local/src

 wget 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" />http://mirror.bit.edu.cn/apache/httpd/httpd-2.2.31.tar.bz2 

3、解壓:

tar -jxvf httpd/httpd-2.2.31.tar.bz2


4、解壓完之後進入到源碼包目錄

cd httpd-2.2.31

如果第一步你沒有文檔參考可以去查看

vim INSTALL

5、配置編譯參數:

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

--prefix=/usr/local/apache2   指定安裝目錄

--with-included-apr \         版本或編譯選項的可能性,apr是apache httpd這個軟體要依賴的一個包,它可以支援httpd,它能夠跨平台去運作,不管是linux還是Windows或是Unix或mic都能去運行httpd,它需要這麼一個底層的包去支援它apr,它可以讓我們去跨平台;

--with-pcre  正則相關的一個庫

--enable-so 表示啟用DSO

DSO是Dynamic Shared Objects(動態共用目標)的縮寫,它提供了一種在運行時將特殊格式的代碼在程式運行需要時,將需要的部分從外存調入記憶體執行的方法。Apache 支援動態共用模組,也支援靜態模組,靜態話,會把需要的目標直接編譯進apache的可執行檔中,相比較動態,雖然省去了載入共用模組的步驟,但是也加大了二進位執行檔案的空間,變得臃腫。

--enable-deflate=shared 表示共用的方式編譯deflate,後面的參數同理。


查看有沒有錯誤

echo $?


如果這一步你出現了這樣的錯誤:

error: mod_deflate has been requested but can not be built due to prerequisite failures

解決辦法是:

yum install -y zlib-devel

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

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



6、如果沒有錯誤

makeecho $?make install


7、查看

ls /usr/local/apache2


8、啟動Apache

/usr/local/apache2/bin/apachectl start

啟動時出現錯誤提示:

httpd: Could not reliably determine the server‘s fully qualified domain name, us    ing localhost.localdomain for ServerName


解決辦法:

1)進入apache的安裝目錄:(視個人安裝情況而不同) [[email protected] ~]# cd /usr/local/apache2/conf
 
2)編輯httpd.conf檔案,搜尋"#ServerName",添加ServerName localhost:80

[[email protected] conf]# lsextra  httpd.conf  magic  mime.types  original[[email protected] conf]# vim httpd.conf#ServerName www.example.com:80ServerName localhost:80

3)再重新啟動apache 即可。

/usr/local/apache2/bin/apachectl restart

9、查看進程

ps aux |grep httpd

10、查看連接埠

netstat -lnp



11、查看經常用到的選項

/usr/local/apache2/bin/apachectl -M

-M把模組列出來其中有一些靜態static,動態載入的shared,檔案路徑

ls /usr/local/apache2/modules

靜態檔案模組路徑

ls /usr/local/apache2/bin/httpd


列出靜態模組

/usr/local/apache2/bin/apachectl -l


查看設定檔有沒有語法錯誤

/usr/local/apache2/bin/apachectl -t


設定檔路徑

ls  /usr/local/apache2/conf/http.conf

可以重啟,關閉,重新載入設定檔

/usr/local/apache2/bin/apachectl restart/usr/local/apache2/bin/apachectl stop/usr/local/apache2/bin/apachectl graceful


12、Apache另一個知識點就是它的工作模式

/usr/local/apache2/bin/apachectl -l

其中有一個prefork.c可以在 ./configure --help 去查看 /--with-map這個選項可以指定它的工作模式,常用的有worker,prefork

本文出自 “12203165” 部落格,請務必保留此出處http://12213165.blog.51cto.com/12203165/1865493

編譯安裝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.