linux下如何把apache作为服务运行?

我自己是加了两句话就可以开机启动的:

chkconfig --add httpd
chkconfig httpd on

前提是用yum 安装 apache

 

其实在源码里已经有启动的脚本,我们要修改下即可,把Apache加入系统SysV服务中来。
在源码httpd-2.x.x/build/rpm中存在httpd.init
cp httpd-2.x.x/build/rpm/httpd.init /etc/init.d/httpd


  长久以来linux下apache的启动是在/etc/rc.d/rc.local文件中添加/opt/www/bin/apachectl start来实现开机启动。

  现在用如下方法可以把apache放入服务中运行。

第一步
cp bin/apachectl /etc/init.d/httpd

第二步
vi /etc/init.d/httpd
加入:
# Startup script for the Apache Web Server
# chkconfig: - 85 15
# description: Apache is a World Wide Web server. It is used to serve
# HTML files and CGI.
# processname: httpd
# pidfile: /opt/www/log/httpd.pid
# config: /opt/www/conf/httpd.conf

第三步
chmod 755 /etc/init.d/httpd
chkconfig --add httpd
chkconfig httpd on

然后就可以使用如下指命启动、停止、重启apache了
service httpd start
service httpd stop
service httpd restart

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值