詳解CentOS設(shè)置程序開機(jī)自啟動(dòng)的方法
在CentOS系統(tǒng)下,主要有兩種方法設(shè)置自己安裝的程序開機(jī)啟動(dòng)。
1、把啟動(dòng)程序的命令添加到/etc/rc.d/rc.local文件中,比如下面的是設(shè)置開機(jī)啟動(dòng)httpd。
#!/bin/sh # # This script will be executed *after* all the other init scripts. # You can put your own initialization stuff in here if you don't # want to do the full Sys V style init stuff. touch /var/lock/subsys/local /usr/local/apache/bin/apachectl start
2、把寫好的啟動(dòng)腳本添加到目錄/etc/rc.d/init.d/,然后使用命令chkconfig設(shè)置開機(jī)啟動(dòng)。
chkconfig 功能說明:檢查,設(shè)置系統(tǒng)的各種服務(wù)。
語法:chkconfig [--add][--del][--list][系統(tǒng)服務(wù)] 或 chkconfig [--level <等級(jí)代號(hào)>][系統(tǒng)服務(wù)][on/off/reset]
--add 添加服務(wù)
--del 刪除服務(wù)
--list 查看各服務(wù)啟動(dòng)狀態(tài)
比如我們?cè)O(shè)置自啟動(dòng)mysql:
#將mysql啟動(dòng)腳本放入所有腳本運(yùn)行目錄/etc/rc.d/init.d中 cp /lamp/mysql-5.0.41/support-files/mysql.server /etc/rc.d/init.d/mysqld #改變權(quán)限 chown root.root /etc/rc.d/init.d/mysqld #所有用戶都可以執(zhí)行,單只有root可以修改 chmod 755 /etc/rc.d/init.d/mysqld #將mysqld 放入linux啟動(dòng)管理體系中 chkconfig --add mysqld #查看全部服務(wù)在各運(yùn)行級(jí)狀態(tài) chkconfig --list mysqld #只要運(yùn)行級(jí)別3啟動(dòng),其他都關(guān)閉 chkconfig --levels 245 mysqld off
例如:我們把httpd的腳本寫好后放進(jìn)/etc/rc.d/init.d/目錄,使用
chkconfig --add httpd chkconfig httpd on
命令即設(shè)置好了開機(jī)啟動(dòng)。
3、把啟動(dòng)程序的命令添加到/etc/rc.d/rc.sysinit 文件中
腳本/etc/rc.d/rc.sysinit,完成系統(tǒng)服務(wù)程序啟動(dòng),如系統(tǒng)環(huán)境變量設(shè)置、設(shè)置系統(tǒng)時(shí)鐘、加載字體、檢查加載文件系統(tǒng)、生成系統(tǒng)啟動(dòng)信息日志文件等
比如我們?cè)O(shè)置自啟動(dòng)apache:
echo "/usr/local/apache2/bin/apachectl start" >> /etc/rc.d/rc.sysinit
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- 詳解Centos7中Nginx開機(jī)自啟動(dòng)的解決辦法
- centos7系統(tǒng)下nginx安裝并配置開機(jī)自啟動(dòng)操作
- CentOS 7安裝Mysql并設(shè)置開機(jī)自啟動(dòng)的方法
- Centos下配置Redis開機(jī)啟動(dòng)腳本
- centos 6.5 oracle開機(jī)自啟動(dòng)的環(huán)境配置詳解
- 詳解Centos7下配置Redis并開機(jī)自啟動(dòng)
- CentOS 開機(jī)啟動(dòng)自定義腳本詳解及實(shí)現(xiàn)
- nginx centos 服務(wù)開機(jī)啟動(dòng)設(shè)置實(shí)例詳解
- Centos 6和Centos 7下服務(wù)啟動(dòng)方法及添加到開機(jī)啟動(dòng)項(xiàng)的方法
- CentOS6 配置Nginx,MySql,php-fpm開機(jī)啟動(dòng)的方法
- Centos7開機(jī)啟動(dòng)自己的腳本的方法
相關(guān)文章
騰訊云服務(wù)器Centos掛載數(shù)據(jù)盤的方法
這篇文章主要介紹了騰訊云服務(wù)器Centos掛載數(shù)據(jù)盤的方法,參考了網(wǎng)上一些資料,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-10-10
Ubuntu下安裝rsh實(shí)現(xiàn)無密碼訪問詳解
這篇文章主要為大家詳細(xì)介紹了Ubuntu下安裝rsh實(shí)現(xiàn)無密碼訪問的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-03-03
linux下/etc/passwd文件的選項(xiàng)說明
/etc/passwd 文件是系統(tǒng)的主要文件之一。該文件中包含了所有用戶登錄名清單;為所有用戶指定了主目錄;在登錄時(shí)使用的 shell 程序名稱等。該文件還保存了用戶口令;給每個(gè)用戶提供系統(tǒng)識(shí)別號(hào)。2008-06-06

