Article Title: Enable Apache to be automatically started when Linux is started. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
The following is a summary of how to enable Apache to start with Linux:
1 cd/etc/init. d
2 vi apache2
3. paste the following code
==========================================================
#! /Bin/sh
# Description: Apache auto start-stop script.
# Chkconfig:-85 15
APACHE_HOME =/usr/local/apache2
APACHE_OWNER = root
If [! -F "$ APACHE_HOME/bin/apachectl"]
Then
Echo "Apache startup: cannot start"
Exit
Fi
Case "$1" in
'Start ')
Su-$ APACHE_OWNER-c "$ APACHE_HOME/bin/apachectl start"
;;
'Stop ')
Su-$ APACHE_OWNER-c "$ APACHE_HOME/bin/apachectl stop"
;;
'Restart ')
Su-$ APACHE_OWNER-c "$ APACHE_HOME/bin/apachectl restart"
;;
Esac
==========================================================
4 chmod + x apache2
5 chkconfig -- add apache2
6 chkconfig-level 345 apache2 on
7 service apache2 start apache server
8. Restart Linux and verify that Apache is started with Linux.
If the above operations are correct, the result should be OK!