天天看点

linux下的apache、mysql自启动

myslq.server的启动脚本程序=》 复制/etc/rc.d/init.d目录

[root@localhost ~]# cd /etc/rc.d/init.d

复制并重命名为mysql

[root@localhost init.d]# cp /usr/local/mysql/support-files/mysql.server mysql

更改属性改为“x”(executable,可执行)

[root@localhost init.d]#  chmod +x mysql

添加到系统的启动服务组中

chkconfig --add mysql

启动服务

service mysql start

另:确认

chkconfig --list [name] 用来列表服务 来确认

chkconfig --list [mysql] 或 chkconfig --list

chkconfig --add name 添加服务

chkconfig --del name  删除服务

2. Apache 自动启动的配置

方法一:

apachectl命令拷贝至/etc/rc.d/init.d目录下,改名为httpd

使用编辑器打开httpd文件,并在第一行#!/bin/sh下增加两行文字如下

# chkconfig: 35 70 30

# description: Apache

接着注册该服务

chkconfig --add httpd

service httpd start

其中所增加的第二行中三个数字第一个表示在运行级别3和5下启动apache,

第二、三是关于启动和停止的优先级配置,无关紧要

方法二: 在/etc/rc.d/rc.local中增加启动apache的命令,例如:/usr/local/httpd/bin/apachectl start

启动服务 

本文转自 小强测试帮 51CTO博客,原文链接:http://blog.51cto.com/xqtesting/808395,如需转载请自行联系原作者