Apache boot script settings

Source: Internet
Author: User

Apache boot script settings

By default, we compile and install apache in the source code, which cannot be started using the service command. Generally, the command we start is:

[Root @ localhost httpd-2.2.16] #/usr/local/apache2/bin/apachectl start

The apachectl in/usr/local/apache2/bin/is actually a STARTUP script. We copy it to/etc/init. d/go and rename it to apache2 (this name can be obtained at will, and you can easily do it yourself)
[Root @ localhost httpd-2.2.16] # cp/usr/local/apache2/bin/apachectl/etc/init. d/apache2

Then modify the two locations to support the service and chkconfig commands.

[Root @ localhost httpd-2.2.16] # vim/etc/init. d/apache2

Add these two lines to any part of the preceding comments:

# Chkconfig: 35 20 80
# Description: Apache2

The three numbers at the end of the first line indicate the running levels of apache (3, 5), startup sequence number (S20), and K80 ).
3 and 5, that is, apache is started by default at the third and fifth startup levels.
20 means that many services need to be started when the system is up, and this program is started in 20th bits, and so on.
80 means that when the system is shut down, the service order is 80th bits.

Note: The two lines are indispensable. The # number must be unique.

Then save and exit, so that we can use the service to start and close apache.
For example:
[Root @ localhost httpd-2.2.16] # service apache2 start
[Root @ localhost httpd-2.2.16] # netstat-antp | grep 80
Tcp 0 0: 80: * LISTEN 13410/httpd

If you want apache to start along with the system, that is, to start automatically, add it to chkconfig.

[Root @ localhost httpd-2.2.16] # chkconfig-add apache2
[Root @ localhost httpd-2.2.16] # chkconfig apache2 on

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.