1.獲取軟件: http://httpd.apache.org/ httpd-2.2.21.tar.gzhtml
2.安裝步驟:apache
解壓源文件:app
1 tar zvxf httpd-2.2.21.tar.gz
2 cd httpd-2.2.21
3 ./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite
4 make
5 make install
運行./configure 命令進行編譯源代碼,編輯器
--prefix=/usr/local/apach2 是設置編譯安裝到的系統目錄,ide
--enable-s 參數是使httpd服務可以動態加載模塊功能,post
--enable-rewrite 是使httpd服務具備網頁地址重寫功能。url
3.啓動apache:code
/usr/local/apache2/bin/apachectl startserver
4.將apache加入到系統服務,用service命令來控制apache的啓動和中止htm
grep -v "#" /usr/local/apache2/bin/apachectl > /etc/init.d/apache
vi /etc/init.d/apache
#!/bin/sh
# chkconfig: 2345 85 15
# description: Apache is a World Wide Web server.
chmod +x /etc/init.d/apache
chkconfig --add apache
chkconfig --list apache
apache 0:off 1:off 2:on 3:on 4:on 5:on 6:off
代表apache服務已經生效,在二、三、四、5運行級別隨系統啓動而自動啓動,之後能夠使用service命令控制Apache的啓動和中止。