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