Linux将源码编译安装的Apache(httpd)服务新增为系统服务
1.查看/etc/init.d/是否存在httpd服务
2.将安装目录下的apachectl复制到该目录下并改名为httpd
cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
将apachectl脚本复制为/etc/init.d/httpd,并将文件开头添加chkconfig识别配置,将其添加为Linux系统服务,文件下面的字符不用删除
#!/bin/sh/
# chkconfig: 35 85 21 //服务级别参数,在3,5级别启动。启动和关闭的顺序为85,21
# description: Startup script for the Apache HTTP Server //服务描述信息
.............. //省略下列信息
[root@localhost httpd-2.4.25]# chkconfig --add httpd //将httpd添加为httpd服务
[root@localhost httpd-2.4.25]#chkconfig httpd on //设置为开机自启
3.查看是否添加成功
[root@localhost httpd-2.4.25]#chkconfig --list httpd
[root@localhost httpd-2.4.25]#netstat -anpt | grep httpd
添加为系统服务成功!