Centos设置开机启动Apache和Mysql
2016-02-26 10:32
651 查看
有两种方法,一种是修改配置文件,一种是通过添加启动项。
方法一:根据系统启动的初始化过程,修改配置文件
Centos中的运行模式2、3、5都把/etc/rc.d/rc.local做为初始化脚本中的最后一个,所以用户可以自己在这个文件中添加一些需要在其他初始化工作之后,登录之前执行的命令。关于rc.d的介绍可以参考:/article/2314170.html。
编辑rc.local文件:#vim /etc/rc.d/rc.local
加入如下启动命令:
#启动apahce
/usr/local/apache/bin/apachectl start
#启动mysql
/usr/local/mysql/bin/mysqld start 或者 /usr/local/mysql/bin/mysqld start
方法二:使用chkconfig命令实现
chkconfig在命令行操作时会经常用到,它可以方便地设置和查询不同运行级上的系统服务chkconfig 语法:
chkconfig [--add] [--del] [--list] [系统服务]
chkconfig [--level/levels] [等级代号] [系统服务] [on/off/reset]
等级代码为:linux系统的运行级别。linux 将操作 环境分为以下7个等级,即
0:关机
1:单用户模式(单用户、无网络)
2:无网络支持的多用户模式(多用户、无网络)
3:有网络支持的多用户模式(多用户、有网络)
4:保留,未使用
5:有网络支持有X-Window支持的多用户模式(多用户、有网络、X-Window界面)
6:重新引导系统,即重启
先用chkconfig list查询apache和mysql服务是否存在,不存在则需要手动添加。
添加apache服务项命令:
chkconfig -add httpd
添加完设置启动项:
chkconfig --level 2345 httpd on
chkconfig --level 2345 mysqld on
方法一:根据系统启动的初始化过程,修改配置文件
Centos中的运行模式2、3、5都把/etc/rc.d/rc.local做为初始化脚本中的最后一个,所以用户可以自己在这个文件中添加一些需要在其他初始化工作之后,登录之前执行的命令。关于rc.d的介绍可以参考:/article/2314170.html。
编辑rc.local文件:#vim /etc/rc.d/rc.local
加入如下启动命令:
#启动apahce
/usr/local/apache/bin/apachectl start
#启动mysql
/usr/local/mysql/bin/mysqld start 或者 /usr/local/mysql/bin/mysqld start
方法二:使用chkconfig命令实现
chkconfig在命令行操作时会经常用到,它可以方便地设置和查询不同运行级上的系统服务chkconfig 语法:
chkconfig [--add] [--del] [--list] [系统服务]
chkconfig [--level/levels] [等级代号] [系统服务] [on/off/reset]
等级代码为:linux系统的运行级别。linux 将操作 环境分为以下7个等级,即
0:关机
1:单用户模式(单用户、无网络)
2:无网络支持的多用户模式(多用户、无网络)
3:有网络支持的多用户模式(多用户、有网络)
4:保留,未使用
5:有网络支持有X-Window支持的多用户模式(多用户、有网络、X-Window界面)
6:重新引导系统,即重启
先用chkconfig list查询apache和mysql服务是否存在,不存在则需要手动添加。
添加apache服务项命令:
chkconfig -add httpd
添加完设置启动项:
chkconfig --level 2345 httpd on
chkconfig --level 2345 mysqld on
相关文章推荐
- win7 64位系统,apache2.4,php5.6.7安
- apache 配置防盗
- 使用Apache Directory Studio初始化Cordys BOP CARS
- Apache配置多域名 AH00548: NameVirtualHost has no effect and will be removed in the next release
- Ubuntu 下快速部署安装 Apache + PHP + MySQL + phpMyAdmin 笔记
- Apache Rewrite配置
- linux 下 apache启动、停止、重启命令
- Read / Write Excel file in Java using Apache POI
- Linux apache单独编译mod_rewrite.so
- apache自动安装脚本(linux)
- 五种开源协议的比较(BSD,Apache,GPL,LGPL,MIT)
- install Apache on CentOS 7
- linux下用Apache一个IP多个网站多域名配置方法
- 练习java jdcb 用apache dbutils 的一些思考
- zendstudio-php开发-调试-debug-环境配置(wampserver=-apache-mysql-php)
- apache 出现Index of /的页面解决
- maven项目建立pom.xml报无法解析org.apache.maven.plugins:maven-resources-plugin:2.4.3
- Apache POI组件操作Excel,制作报表(一)
- PHP开发Apache服务器配置
- apache的动态和静态