Linux设置Apache开机启动
2022-06-05PHP
在Linux下,如果是yum安装Apache,则会默认把服务添加进系统服务中,只需要使用chkconfig来设置开机启动就可以实现Apache开机启动。但如果编译安装Apache,则需要先把Apache添加到系统服务中心,或者直接把启动命令添加到系统启动文件中。下面详细的讲一下编译安装Apache设置开机启动。
Linux设置Apache开机启动方法一:将apache加入到系统服务
1、将Apache启动命令复制到系统服务启动目录。
1 | [root@LAMP LAMP]# cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd |
2、编辑/etc/init.d/httpd文件,使用把Apache加入到系统服务。
1 | [root@LAMP LAMP]# chkconfig --add httpd |
chkconfig –add httpd的时候出现错误:service httpd does not support chkconfig。则需要在/etc/init.d/httpd文件中加入chkconfig相关配置。
1 | [root@LAMP LAMP]# vi /etc/init.d/httpd |
3、使用chkconfig将Apache设置开机启动。
1 | [root@LAMP LAMP]# chkcongfig httpd on |
Linux设置Apache开机启动方法二:将Apache开机启动脚本写入/etc/rc.d/rc.local,定义开机自动启动的程序。
1、编辑/etc/rc.d/rc.local文件,在文件底部加上Apache启动命令。
1 | [root@LAMP LAMP]# vi /etc/rc.d/rc.local |
很赞哦! ()