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