apache安裝配置

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

  •  首先以apachectl腳本爲模板生成Apache服務控制腳本:

  grep -v "#" /usr/local/apache2/bin/apachectl  > /etc/init.d/httpd編譯

  • 用vi編輯Apache服務控制腳本/etc/init.d/httpd:

  vi /etc/init.d/httpd

  • 在文件最前面插入下面的行,使其支持chkconfig命令:

  #!/bin/sh              

  # chkconfig: 2345 85 15              

  # description: Apache is a World Wide Web server.

  • 保存後退出vi編輯器,執行下面的命令增長Apache服務控制腳本執行權限:    

  chmod  +x  /etc/init.d/httpd

  • 執行下面的命令將Apache服務加入到系統服務:    

  chkconfig --add httpd

  • 執行下面的命令檢查Apache服務是否已經生效:    

  chkconfig --list httpd              

  • 命令輸出相似下面的結果:              

  httpd          0:off 1:off 2:on 3:on 4:on 5:on 6:off       

  代表httpd服務已經生效,在二、三、四、5運行級別隨系統啓動而自動啓動,之後能夠使用service命令控制httpd的啓動和中止。  

  • 啓動httpd服務:   service httpd start   
  • 中止httpd服務:        service httpd stop   
  • 執行下面的命令關閉開機自啓動:      chkconfig httpd off
相關文章
相關標籤/搜索