Detailed CentOS set the program to boot the method _linux

Source: Internet
Author: User
Tags centos

Under the CentOS system, there are two main ways to set up your own installed programs to boot.

1, the start of the program to add the command to the/etc/rc.d/rc.local file, such as the following is the setting up boot httpd.

#!/bin/sh # This script would be executed *after* all the other
init scripts.
# You can put your own initialization stuff in-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, add the written startup script to the directory/etc/rc.d/init.d/, and then use the command chkconfig to set the boot up.

Chkconfig function Description: Check, set up the system of various services.

Syntax: chkconfig [--add][--del][--list][system Services] or Chkconfig [--level < rank code >][system Services][on/off/reset]

--add Add Service

--del Delete Service

--list View each service startup status

For example, we set the self-boot mysql:

#将mysql启动脚本放入所有脚本运行目录/ETC/RC.D/INIT.D in
cp/lamp/mysql-5.0.41/support-files/mysql.server/etc/rc.d/init.d/ Mysqld

#改变权限
chown root.root/etc/rc.d/init.d/mysqld

#所有用户都可以执行, only root can modify
chmod 755/etc/rc.d/ Init.d/mysqld

#将mysqld into the Linux boot management system
chkconfig--add mysqld

#查看全部服务在各运行级状态
chkconfig--list mysqld

#只要运行级别3启动, all others close
chkconfig--levels 245 mysqld off

For example: We write the httpd script and put it into the/etc/rc.d/init.d/directory, using

Chkconfig--add httpd
chkconfig httpd on

The command is set to boot.

3, the start of the program to add the command to the/etc/rc.d/rc.sysinit file

Script/etc/rc.d/rc.sysinit, complete system service program startup, such as system environment variable setting, setting system clock, loading font, checking loading file system, generating system startup information log file, etc.

For example, we set up self-booting Apache:

echo "/usr/local/apache2/bin/apachectl start" >>/etc/rc.d/rc.sysinit

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.