linux下原始碼包安裝apache
系統環境:CentOS 6.5 原始碼包:httpd-2.2.22.tar.gz
解除安裝原有的apache
1、查詢原有安裝的
rpm -qa |grep httpd
2、根據查出來的結果中刪除
rpm -e --nodeps httpd-tools-2.2.15-29.el6.centos.x86_64
rpm -e --nodeps httpd-2.2.15-29.el6.centos.x86_64
rpm -e --nodeps httpd-manual-2.2.15-29.el6.centos.noarch
安裝編譯apache所用到的包
yum -y install gcc gcc++ zlib zlib-devel
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
上傳apache原始碼包
ftp或者rz,也可直接下載
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
解壓原始碼包
tar -zxvf httpd-2.2.22.tar.gz
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
進入所解壓的目錄下
cd httpd-2.2.22
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
編譯檔案
./configure
後面可以加引數,引數說明如下:
--prefix=/usr/local/apache2 apache的安裝路徑,預設安裝路徑為/usr/local/apache2
--enable-rewrite 使伺服器具有URL網頁地址重寫功能(據說訪問不了偽靜態頁面,這個主要關係於SEO)
--enable-so 啟用apache服務的DSO (Dynamic Shared Objects動態共享目標)
--enable-headers 提供允許對HTTP請求頭的控制。
--enable-expires 通過配置檔案控制HTTP的“Expires:”和“Cache-Control:”頭內容,提供客戶端瀏覽器快取的設定。
--with-mpm=worker 選擇apache mpm的模式為worker模式。(MPM多路處理模組)
--enable-deflate 提供對內容的壓縮傳輸編碼支援
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------安裝
make &&make install
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
如果按上面步驟安裝,那麼安裝路徑是在/usr/local/apache2
啟動: /usr/local/apache2/bin/apachectl start
重啟:/usr/local/apache2/bin/apachectl restart
停用:/usr/local/apache2/bin/apachectl stop
如果啟動出現下面這個,
httpd: Could not reliably determine the server's fully qualified domain name, using .......... for ServerName
修改配置檔案/usr/local/apache2/conf/httpd.conf如下(去掉註釋改為 ServerName localhost:80)
伺服器日誌: /usr/local/apache2/logs/access_log
監控伺服器: tail -f /usr/local/apache2/logs/access_log (常用)
錯誤日誌:/usr/local/apache2/logs/error_log
如果還是開不了網頁,檢視防火牆。可直接關閉,或者修改 /etc/sysconfig/iptables。預設是隻開了22埠