linux设置开机启动

来源:互联网 发布:软件max 编辑:程序博客网 时间:2024/04/29 04:03

如果你都是按照默认配置安装的那么只要按照如下步骤就可以了

 

1、cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql   将服务文件拷贝到init.d下,并重命名为mysql

2、chmod +x /etc/init.d/mysql    赋予可执行权限

3、chkconfig --add mysql        添加服务

4、chkconfig --list             显示服务列表


如果看到mysql的服务,并且3,4,5都是on的话则成功,如果是off,则键入

chkconfig --level 345 mysql on
5、reboot重启电脑
6、netstat -na | grep 3306,如果看到有监听说明服务启动了

 



Linux下添加服务  (service httpd start 不能被识别的解决办法)

  

service httpd restart   出现 httpd:unrecognized service 错误

vi /etc/rc.local #在/etc/rc.d/rc.local中增加启动apache的命令
添加:
/usr/local/apache2/bin/apachectl start
或者               

 #将apache注册为系统服务

cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd

#chmod 700 /etc/rc.d/init.d/httpd
#vi /etc/rc.d/init.d/httpd
   在第三行后增加
   #Comments to support chkconfig on RedHat Linux
   #chkconfig: 2345 90 90
   #description:http server
注意:没有这几行,在使用chkconfig时会提示你:service httpd does not support chkconfig。
chkconfig --add httpd
chkconfig --level 2345 httpd on





0 0