1. 程式人生 > >在centos中 將apache httpd 服務加入系統服務

在centos中 將apache httpd 服務加入系統服務

httpd服務啟動

如果沒有httpd 服務的時候,每次啟動都要/usr/local/apache/bin/apachectl start好難受的說,

下面就將httpd裝到服務中,同理也可以用到其他服務的操作。

cd /etc/init.d //切換到這個目錄可以查看系統服務有哪些 檢查httpd是不是系統服務

步驟將apache服務添加到系統服務裏

Apache加入到系統服務裏面:
  cp /安裝目錄下/apache/bin/apachectl /etc/rc.d/init.d/httpd

第二步 運行chkconfig --list 看是否有apache服務

如果沒有則使用

2.運行chkconfig –list 發現列表中沒有httpd,通過chkconfig –add httpd來添加,可能會提示httpd服務不支持chkconfig,需要編輯/etc/rc.d/init.d/httpd

添加以下註釋信息:

# chkconfig: 345 85 15
# description: Activates/Deactivates Apache Web Server
345代表哪些linux級別需要啟動httpd, 啟動序號是85, 關閉序號是15

3.運行chkconfig –list,httpd 就存在了,可以使用service httpd start 和 service httpd stop來啟動和停止服務。


在centos中 將apache httpd 服務加入系統服務