linux httpd 开机启动,Linux设置Apache开机启动

在Linux下,如果是yum安装Apache,则会默认把服务添加进系统服务中,只需要使用chkconfig来设置开机启动就可以实现Apache开机启动。但如果编译安装Apache,则需要先把Apache添加到系统服务中心,或者直接把启动命令添加到系统启动文件中。下面雷雪松详细的讲一下编译安装Apache设置开机启动。

Linux设置Apache开机启动方法一:将apache加入到系统服务

1、将Apache启动命令复制到系统服务启动目录。

[root@LAMP LAMP]# cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd

2、编辑/etc/init.d/httpd文件,使用chkconfig把Apache加入到系统服务。

[root@LAMP LAMP]# chkconfig --add httpd

chkconfig –add httpd的时候出现错误:service httpd does not support chkconfig。则需要在/etc/init.d/httpd文件中加入chkconfig相关配置。

[root@LAMP LAMP]# vi /etc/init.d/httpd

#chkconfig:345 85 15

#description: Start and stops the Apache HTTP Server.

3、使用chkconfig将Apache设置开机启动。

[root@LAMP LAMP]# chkcongfig httpd on

Linux设置Apache开机启动方法二:将Apache开机启动脚本写入/etc/rc.d/rc.local,定义开机自动启动的程序。

1、编辑/etc/rc.d/rc.local文件,在文件底部加上Apache启动命令。

[root@LAMP LAMP]# vi /etc/rc.d/rc.local

/usr/local/httpd/bin/apachectl start。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值