將httpd加入centos的系統(tǒng)服務(wù)
- 來(lái)源:縱橫數(shù)據(jù)
- 作者:中橫科技
- 時(shí)間:2013/1/7 14:54:27
- 類別:新聞資訊
系統(tǒng)服務(wù)里面沒(méi)有apache或者h(yuǎn)ttpd服務(wù),每次啟動(dòng)都要
/usr/local/apache2/bin/apachectl start
比較麻煩,下面的操作可以將httpd裝入到服務(wù)中,同理也可以用到其他的服務(wù)操作
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的意義后面介紹)
此時(shí)Apache就可以自動(dòng)啟動(dòng)了。
2、 運(yùn)行chkconfig –list,發(fā)現(xiàn)沒(méi)有l(wèi)inux服務(wù)列表中httpd,通過(guò)chkconfig –add httpd來(lái)添加,但是提示:httpd服務(wù)不支持 chkconfig。需要編輯/etc/rc.d/init.d/httpd,添加以下注釋信息:
# chkconfig: 345 85 15
# description: Activates/Deactivates Apache Web Server
第一行3個(gè)數(shù)字參數(shù)意義分別為:哪些Linux級(jí)別需要啟動(dòng)httpd(3,4,5);啟動(dòng)序號(hào)(85);關(guān)閉序號(hào)(15)。
保存后執(zhí)行:chkconfig --add httpd,成功添加。
在rc3.d、rc4.d、rc5.d路徑中會(huì)出現(xiàn)S85httpd的鏈接文件,其他運(yùn)行級(jí)別路徑中會(huì)出現(xiàn)K61httpd的鏈接文件。 縱橫數(shù)據(jù)提供技術(shù)支持
3、運(yùn)行chkconfig --list httpd 縱橫數(shù)據(jù)