將httpd加入centos的系統服務
系統服務里面沒有apache或者httpd服務,每次啟動都要
/usr/local/apache2/bin/apachectl start
比較麻煩,下面的操作可以將httpd裝入到服務中,同理也可以用到其他的服務操作
1、將apachectl文件拷貝到/etc/rc.d/init.d 中,然后在/etc/rc.d/rc5.d/下加入鏈接即可。
命令如下:
cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd //如果有其他的版本的Apache存在,也可以直接覆蓋掉
ln -s /etc/init.d/httpd /etc/rc.d/rc5.d/S85httpd //建立鏈接(85的意義后面介紹)
此時Apache就可以自動啟動了。
2、 運行chkconfig –list,發現沒有linux服務列表中httpd,通過chkconfig –add httpd來添加,但是提示:httpd服務不支持 chkconfig。需要編輯/etc/rc.d/init.d/httpd,添加以下注釋信息:
# chkconfig: 345 85 15
# description: Activates/Deactivates Apache Web Server
第一行3個數字參數意義分別為:哪些Linux級別需要啟動httpd(3,4,5);啟動序號(85);關閉序號(15)。
保存后執行:chkconfig --add httpd,成功添加。
在rc3.d、rc4.d、rc5.d路徑中會出現S85httpd的鏈接文件,其他運行級別路徑中會出現K61httpd的鏈接文件。 縱橫數據提供技術支持
3、運行chkconfig --list httpd 縱橫數據