How the httpd service boots up

Source: Internet
Author: User


In the previous study we already know how to receive the start service or stop the service, to httpd service in REDHAT5, CENTOS6 for example:

Start the service:

Service httpd Start

Stop service:

Service httpd Stop

Restart Service:

Service HTTP Restart


So how do we set up a httpd service boot?

Method One:

We can use the NTSYSV command to view, with * For start-up services, without * for power-on does not start the service, can also be set manually, but the settings only work in the current mode, switch to another mode is not valid

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M00/06/C8/wKiom1m-WlaDCGphAABOFGRG1yY935.png "title=" Qq20170917182902.png "alt=" Wkiom1m-wladcgphaabofgrg1yy935.png "/>

We know that Linux has multiple modes of operation to view/etc/initab files

650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M00/A5/78/wKioL1m-Wj6Q1TJUAACIJGoLJ9c391.png "title=" Qq20170917183216.png "alt=" Wkiol1m-wj6q1tjuaacijgolj9c391.png "/>


Method Two: Use the script to create the boot start service

1, LS/ETC/INIT.D

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M01/A5/78/wKioL1m-Wl_izSaVAABcnrr3ml0338.png "title=" Qq20170917184229.png "alt=" Wkiol1m-wl_izsavaabcnrr3ml0338.png "/>

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M02/A5/78/wKioL1m-Wnqi_yTbAAA3BTnPPMM934.png "title=" Qq20170917185010.png "alt=" Wkiol1m-wnqi_ytbaaa3btnppmm934.png "/>

We found that the system already has a httpd service script, if you do not need to write scripts and move to the/ETC/INIT.D directory, we need to note that the script as a service must have the following two lines

Chkconfig:-85 15

-Represents the work which mode, want to set to which mode is set to which mode, for example can set in 3,5 mode to write 35 middle does not need any symbol here we do not specify

85 The first number represents the starting run order s*: s##*:# #运行次序; The smaller the number, the more first it runs; number

The smaller the service, usually the service that is to be relied upon

15 The second number represents the order of the Stop k*: k##*:# #运行次序; The smaller the number, the more first it runs; number

The smaller the service, the more often it is dependent on other services

In short, for example, a service to rely on network services in mode 3 under the Network service order is S10, we write the service must be open after the network service is turned on, and shut down before the network service shutdown, or the network service cannot shut down, so the s value should be larger, the K value should be smaller

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M00/06/C8/wKiom1m-WvCCEqm0AABuJY58kNk982.png "title=" Qq20170917190118.png "alt=" Wkiom1m-wvcceqm0aabujy58knk982.png "/>

Description

If you want to write your own script as a startup service in the script you need to pay attention to several aspects:

A script cannot call a separate function

Cannot be interactive

Have Execute permission


2. Chkconfig command to view the startup or shutdown settings for the service at all levels

Chkconfig--list httpd View all powered-on services found no httpd

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M01/06/C8/wKiom1m-WzzigFakAAAK8BSVyTw559.png "style=" float : none; "title=" Qq20170917191032.png "alt=" Wkiom1m-wzzigfakaaak8bsvytw559.png "/>

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M01/06/C8/wKiom1m-WzyggPqEAABugYd6_XM531.png "style=" float : none; "title=" Qq20170917191603.png "alt=" Wkiom1m-wzyggpqeaabugyd6_xm531.png "/>

3, Chkconfig--add httpd Add script to boot list, but it is not running boot

4, because we do not specify in which mode the HTTPD service script is running, you can set it here, for example I want to boot up in the current mode

View current mode first: RunLevel

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M00/A5/78/wKioL1m-Ww3wWOTeAAAJaQCoxKw634.png "style=" float : none; "title=" Qq20170917191331.png "alt=" Wkiol1m-ww3wwoteaaajaqcoxkw634.png "/>

Chkconfig--level 5 httpd on

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M00/A5/78/wKioL1m-Ww2R85y8AAAMMWp8LTU458.png "style=" float : none; "title=" Qq20170917191433.png "alt=" Wkiol1m-ww2r85y8aaammwp8ltu458.png "/>

At this point the view/etc/rc.d/rc5.d found that starting with S run sequence is 85

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M02/06/C8/wKiom1m-Wz2jxJFTAABwrox-UUc545.png "style=" float : none; "title=" Qq20170917191726.png "alt=" Wkiom1m-wz2jxjftaabwrox-uuc545.png "/>

In other modes, such as 3, the starting order of K is 15.

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M01/A5/78/wKioL1m-Ww3jZ1uxAABy_EEnkfo825.png "style=" float : none; "title=" Qq20170917191705.png "alt=" Wkiol1m-ww3jz1uxaaby_eenkfo825.png "/>

5, restart, command service httpd Status View specified mode HTTPD service is not powered on


Such a boot start service is ready!


How the httpd service boots up

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.