Linux下注册Apache为系统服务



2009-03-11 18:21:43| 分类: Linux |字号 订阅

vi /etc/rc.d/rc.local
增加:/usr/local/httpd/bin/apachectl start

2:[注册为Service]
cp /usr/local/httpd/bin/apachectl /etc/rc.d/init.d/httpd
vi httpd
找到:#!/bin/sh
另起一行,增加:
# chkconfig: 35 70 30
# description: Apache
Ok~
然后注册服务:chkconfig --add httpd
----
启动服务:service httpd start
停止服务:service httpd stop
重新启动:service httpd restart

又搜了一下其他的方法:
mysql设为linux服务

cp /usr/local/mysql5/share/mysql/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 2345 mysqld on
chown mysql:mysql -R /usr/local/mysql5/
service mysqld start

apache设为linux服务

cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd
vi /etc/init.d/httpd

在在#!/bin/sh后面加入下面两行
#chkconfig:345 85 15
#description: Start and stops the Apache HTTP Server.

然后
chmod +x /etc/rc.d/init.d/httpd
chkconfig --add httpd

原文地址:https://www.cnblogs.com/roland1982/p/3511792.html