Apache Boot script settings

Source: Internet
Author: User

By default we compile the source code to install Apache, it is not possible to use the service this command to start, usually we start the command is:

[[email protected] httpd-2.2.16]#/usr/local/apache2/bin/apachectl start

/usr/local/apache2/bin/in the Apachectl is actually a startup script, we copy him to/etc/init.d/, and renamed to Apache2 (this name casually, you can easily do)
[Email protected] httpd-2.2.16]# cp/usr/local/apache2/bin/apachectl/etc/init.d/apache2

Then modify 2 places to let him support service and Chkconfig commands

[Email protected] httpd-2.2.16]# vim/etc/init.d/apache2

Add these 2 lines anywhere in the previous large comment:

# chkconfig:35 20 80
# Description:apache2

The 3 numbers that follow the first line are the following: the operating level at which you start Apache (3,5), the start Sequence number (S20), and the close ordinal (K80).
3 and 5 means that Apache is started by default at the third boot level and the fifth boot level
20 refers to the system up when there are a lot of services need to start, and this program is ranked in the 20th bit start, and so on
80 means that when the system shuts down, the order of service is closed in 80th place.

Note: These 2 lines are indispensable, #号不能省略, must have

Then save the exit so we can start and close Apache with the service
Like what:
[[Email protected] httpd-2.2.16]# service apache2 start
[Email protected] httpd-2.2.16]# NETSTAT-ANTP |grep 80
TCP 0 0::: +:::* LISTEN 13410/httpd

If you want Apache to follow the system to boot, that is, boot from the boot, then add to Chkconfig can

[Email protected] httpd-2.2.16]# Chkconfig–add apache2
[Email protected] httpd-2.2.16]# chkconfig apache2 on

Apache Boot script settings

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.