Linux下将Apache(httpd)新增为系统服务及开机自启动

转自:http://www.linuxidc.com/Linux/2012-11/74517p2.htm


1> 查看一下/etc/init.d/下是否存在httpd这个服务

ls /etc/init.d/ | grep httpd 如果没有执行下一步

2>将自己安装目录下的apachect1复制到该目录下并改为httpd

cp /home/houqingdong/http-exe/bin/apachect1 /etc/init.d/httpd 注:红色为自己的安装目录

3>执行 chkconfig --add httpd 目的是想新增所制定的系统服务 但是会出现以下警告:

Linux下将Apache(httpd)新增为系统服务及开机自启动

这里说的是httpd服务不支持chkconfig , 添加支持: vi /etc/init.d/httpd 在 #!/bin/sh 下添加这两句:

#chkconfig:345 85 15

#description:Start and stop the Apache HTTP Server 最终结果为:

Linux下将Apache(httpd)新增为系统服务及开机自启动

4> 执行: chkconfig --add httpd

chkconfig httpd on 就可以添加成功了

5>查看一下是否添加成功:

chkconfig --list httpd

Linux下将Apache(httpd)新增为系统服务及开机自启动



Linux 设置Apche+MySQL开机启动

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
然后可以用setup命令进入服务设置,设置为开机启动
 
第二种方法:
 
在/etc/rc.d/rc.local中增加启动apache的命令,例如:/usr/local/httpd/bin/apachectl start


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值