Home  >  Article  >  Database  >  Linux下源码安装Apache+MySQL后自动启动设置

Linux下源码安装Apache+MySQL后自动启动设置

WBOY
WBOYOriginal
2016-06-07 16:59:001055browse

由于Linux版本的不同:自动启动的shell脚本放置的位置和名称也不相同,在redhat、红旗等版本的linux中启动脚本放在 /etc/rc.d目录

由于Linux版本的不同:自动启动的shell脚本放置的位置和名称也不相同,在RedHat、红旗等版本的linux中启动脚本放在 /etc/rc.d目录中,名称是:rc.local。而SUSE版本的linux启动脚本是放在/etc/init.d目录中,名称 boot.local.
例如:apache、mysql自动启动

在红旗、radhat等linux中如下
#cd /etc/rc.d
#vi rc.local
在rc.local加入:
/usr/local/apache/bin/apachectl start
/usr/local/mysql/bin/mysqld_safe --user=mysql &

在suse中如下
#cd /etc/init.d
#vi boot.local
在rc.local加入:
/usr/local/apache/bin/apachectl start
/usr/local/mysql/bin/mysqld_safe --user=mysql &

方法2:

在Linux系统中我一般采用编译源码的方式来安装Apache,有两种方法可以让Apache在系统启动时自动启动。

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

2. 将apache注册为系统服务

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

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

# chkconfig: 35 70 30
# description: Apache

接着注册该服务

chkconfig --add httpd

一切OK了,,启动服务

service httpd start

其中所增加的第二行中三个数字第一个表示在运行级别3和5下启动apache,第二、三是关于启动和停止的优先级配置,无关紧要。

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn