Apache自動啟動及添加為Linux的服務 轉自:http://www.51testing.com/?27242/action_viewspace_itemid_78916.html

來源:互聯網
上載者:User

轉自:http://www.51testing.com/?27242/action_viewspace_itemid_78916.html,根據Apache2的版本,略有修改


說明:
 Apache安裝路徑為:/usr/local/apache2
 Linux的啟動層級為5,版本為Linux AS4

 Apache安裝完後,發現Apache無法自動啟動,查看/etc/rc.d/rc5.d/下,應該沒有S打頭,httpd結尾的連結檔案。

1、將apachectl檔案拷貝到/etc/rc.d/init.d 中,然後在/etc/rc.d/rc5.d/下加入連結即可。
命令如下:
cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd  //如果有其他的版本的Apache存在,也可以直接覆蓋掉。
ln -s /etc/rc.d/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
  # descrīption: Apache
    第一行3個數字參數意義分別為:哪些Linux層級需要啟動httpd(3,4,5);啟動序號(85);關閉序號(15)。

儲存後執行:chkconfig --add httpd,成功添加。

在rc3.d、rc4.d、rc5.d路徑中會出現S85httpd的連結檔案,其他運行層級路徑中會出現K61httpd的連結檔案。

3、運行chkconfig --list | grep httpd,http在其中。

重啟後,查看已啟動的服務:

chkconfig --list | grep httpd,可以發現httpd

在RedHat或CentOS中,可以運行ntsysv來設定自啟動服務

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.