It turns out that Apache needs to be registered with the Linux service!
Registering Apache to Linux services
After installing Apache in source code mode under Linux, booting off Apache can be accomplished by the following command:
/usr/local/apache/bin/apachectl start | stop | restart
If you want to include httpd in a system-initiated service, you can copy the above apachectl files directly into/ETC/RC.D/INIT.D, and then add the links to the appropriate boot level, such as 3,5. The command is as follows:
/usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd # 复制到init.d 并重命名为httpdln -s /etc/rc.d/init.d/httpd /etc/rc.d/rc3.d/S61httpd
The S61 of the linked file is the ordinal at startup. When the INIT.D directory has a httpd script, we can start off Apache by using the service command. Execute under Any path:
stop | restart
Then there is a problem is: Although Apache can automatically start, but in the list of Linux services do not see it, to add services, generally through chkconfig--add xxx to achieve, but need to have the appropriate information in the script, otherwise chkconfig will prompt: XXX The service does not support Chkconfig. So we first edit the httpd script, and in line 2nd (#!/bin/sh below) Add the following comment information (including #):
# chkconfig: 35 61 61# description: Apache
The 3 parameters for the first line are: at which RunLevel, start httpd (3,5), start sequence number (S61), and close ordinal (K61). Note: The description of the second line must be written!
Save after execution:
chkconfig --add httpd #所有开机模式下自启动,另外chkconfig httpd on 表示345模式下自启动
The httpd is added to the service. S61HTTPD links will appear in the RC3.D, rc5.d path in the future, and k61httpd links will appear in other run-level paths.
Run the following command to view the service, and you will see the httpd service.
Chkconfig--list
Latest Cenos Execution Service httpd Restart error failed to restart Httpd.service:Unit not found.