#tar zxvf httpd-2.2.11.tar.gz
解壓apache包,在當前目錄下生成httpd-2.2.11
#cd httpd-2.2.11.tar.gz
進入httpd-2.2.11目錄
#./configure –prefix=/usr/local/apache2 –enable-so -enable-mods-shared=most –enable-rewrite –enable-cache
其中的-enable要用空格連起來寫
–prefix指定安裝目錄
–enable-so選項:讓Apache可以支持DSO模式,注意,這裏採用的是Apache2.0的語法。使用1.3版本的將其改爲–enable-module=so。
–enable-mods-shared=most選項:告訴編譯器將所有標準模塊都編譯爲DSO模塊。使用1.3版本的將其改爲–enable-shared=max。此方式是動態加載所有模塊,如果去掉-shared話,是靜態加載所有模塊。”most”表示大部分常用的模塊,”all”表示所有模塊(–enable-mods-shared=all)
–enable-rewrite(實現對動態網頁地址的重寫)選項:支持地址重寫功能,使用1.3版本的將其改爲–enable-module=rewrite。
#make;make install 編譯並且安裝
#cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd
#service httpd start/stop
立即啓動apache服務,重啓後無效
開機自啓動apache服務器
a:
echo “/usr/local/apache2/bin/apachectl start” >> /etc/rc.local
b:
vi /etc/rc.d/init.d/httpd (就是上面複製的文件)
添加入下code
# Comments to support chkconfig on Centos
# chkconfig: 2345 50 90
# description: Activates/Deactivates Apache Web Server
#description一定要有,否則httpd腳本就會出錯
這樣就可以通過chkconfig配置自啓動了