Linux配置Nginx,MySql,php-fpm开机启动的方法
一. Nginx 开机启动
1、在/etc/init.d/目录下创建脚本
vim /etc/init.d/nginx
2、编写脚本内容 (将以下复制进去相应改动安装路径)
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
#!/bin/bash# nginx Startup script for the Nginx HTTP Server# it is v.0.0.2 version.# chkconfig: - 85 15# description: Nginx is a high-performance web and proxy server.# It has a lot of features, but it's not for everyone.# processname: nginx# pidfile: /var/run/nginx.pid# config: /usr/local/nginx/conf/nginx.conf //这里改成之前的安装目录nginxd=/usr/local/webserver/nginx/sbin/nginx //这里改成之前的安装目录nginx_config=/usr/local/webserver/nginx/conf/nginx.conf //这里改成之前的安装目录nginx_pid=/usr/local/webserver/nginx/logs/nginx.pid //这里改成之前的安装目录RETVAL=0prog="nginx"# Source function library.. /etc/rc.d/init.d/functions# Source networking configuration.. /etc/sysconfig/network# Check that networking is up.[ ${NETWORKING} = "no" ] && exit 0[ -x $nginxd ] || exit 0# Start nginx daemons functions.start() {if [ -e $nginx_pid ];thenecho "nginx already running...."exit 1fiecho -n $"Starting $prog: "daemon $nginxd -c ${nginx_config}RETVAL=$?echo[ $RETVAL = 0 ] && touch /var/lock/subsys/nginxreturn $RETVAL}# Stop nginx daemons functions.stop() {echo -n $"Stopping $prog: "killproc $nginxdRETVAL=$?echo[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /usr/local/webserver/nginx/logs/nginx.pid}reload() {echo -n $"Reloading $prog: "#kill -HUP `cat ${nginx_pid}`killproc $nginxd -HUPRETVAL=$?echo}# See how we were called.case "$1" instart)start;;stop)stop;;reload)reload;;restart)stopstart;;status)status $progRETVAL=$?;;*)echo $"Usage: $prog {start|stop|restart|reload|status|help}"exit 1esacexit $RETVAL |
3、更改脚本权限
|
1
|
chmod 775 /etc/init.d/nginx |
4、设置开机启动
|
1
|
#chkconfig nginxd on |
二. MySQL开机启动
1、将mysql安装目录下 support-files目录下的mysql.server文件拷贝到/etc/init.d/目录下并改名为mysqld,并更改权限
|
1
|
chmod 775 /etc/init.d/mysqld |
2、设置开机启动
|
1
|
#chkconfig mysqld on |
三. PHP-fpm开机启动
1、在/etc/init.d/目录下创建脚本
|
1
|
vim /etc/init.d/php-fpm |
2、编写脚本内容 (将以下复制进去相应改动安装路径)
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
#!/bin/sh## php-fpm - this script starts and stops the php-fpm daemin## chkconfig: - 85 15# processname: php-fpm# config: /usr/local/php/etc/php-fpm.confset -ePATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/binDESC="php-fpm daemon"NAME=php-fpmDAEMON=/usr/local/php/sbin/$NAME //这里改成之前的安装目录CONFIGFILE=/usr/local/php/etc/php-fpm.conf //这里改成之前的安装目录PIDFILE=/usr/local/php/var/run/$NAME.pid //这里改成之前的安装目录SCRIPTNAME=/etc/init.d/$NAME //这里改成之前的安装目录 # If the daemon file is not found, terminate the script.test -x $DAEMON || exit 0d_start(){$DAEMON -y $CONFIGFILE || echo -n " already running"}d_stop(){kill -QUIT `cat $PIDFILE` || echo -n " no running"}d_reload(){kill -HUP `cat $PIDFILE` || echo -n " could not reload"}case "$1" instart)echo -n "Starting $DESC: $NAME"d_startecho ".";;stop)echo -n "Stopping $DESC: $NAME"d_stopecho ".";;reload)echo -n "Reloading $DESC configuration..."d_reloadecho "Reloaded.";;restart)echo -n "Restarting $DESC: $NAME"d_stop# Sleep for two seconds before starting again, this should give the nginx daemon some time to perform a graceful stopsleep 2d_startecho ".";;*)echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload)" >&2exit 3;;esacexit 0 |
最后:x 保存退出
3、更改脚本权限
|
1
|
chmod 775 /etc/init.d/php-fpm |
4、设置开机启动
|
1
|
#chkconfig php-fpm on |
可用命令 chkconfig 查看开机启动服务列表!
Linux配置Nginx,MySql,php-fpm开机启动的方法的更多相关文章
- Linux下设置mysql和tomcat开机启动
本文基于CentOS 64位 一.mysql设置开机启动 1.cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql ...
- Linux 下配置Nginx,MySql,php-fpm开机启动
一. Nginx 开机启动 1.在/etc/init.d/目录下创建脚本 vim /etc/init.d/nginx 2.编写脚本内容 (将以下复制进去相应改动安装路径) #!/bin/bash # ...
- Linux/CentOS 服务安装/卸载,开机启动chkconfig命令详解|如何让MySQL、Apache开机启动?
chkconfig chkconfig在命令行操作时会经常用到.它可以方便地设置和查询不同运行级上的系统服务.这个可要好好掌握,用熟练之后,就可以轻轻松松的管理好你的启动服务了. 注:谨记chkcon ...
- 阿里云Linux服务器安装 nginx+mysql+php
阿里云Linux服务器安装 nginx+mysql+php步骤1.登录服务器2.下载安装包3.将安装包上传到服务器的/home目录下 注:使用rz sz命令进行本地和服务器间的上传.下载,安装命令yu ...
- Linux配置Nginx+Tomcat负载均衡
cd /usr/local/tomcat1/webapps/ROOT/ tar -zxvf nginx-1.14.2.tar.gz -C /usr/local 一.Linux配置Nginx 一.下载N ...
- Linux开机启动chkconfig命令详解(让MySQL、Apache开机启动)
chkconfig chkconfig在命令行操作时会经常用到.它可以方便地设置和查询不同运行级上的系统服务.这个可要好好掌握,用熟练之后,就可以轻轻松松的管理好你的启动服务了. 注:谨记chkcon ...
- linux的MySQL设为开机启动
linux开启启动的程序一般放在/etc/rc.d/init.d/里面,/etc/init.d/是其软连接 mysql设为linux服务cp /usr/local/mysql5/share/mysql ...
- windows下配置Nginx+Mysql+Php7
环境:Windows10 mysql-5.6.24-win32解压缩版 nginx-1.8.0 php7 1.Mysql安装 下载压缩文件之后解压缩至相应目录(我的目录是G:\wnmp\m ...
- Linux系统中svn服务器设置开机启动
安装完svn服务器后虽然好用但是因为经常重启Linux服务器,每次重启完就要去手动启动svn服务器,很是麻烦,于是在网上找了一些方法后,自己把svn服务器设置成开机启动 步骤一:安装svn服务器: h ...
随机推荐
- selenium测试(Java)--下拉框(二十一)
例子: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title ...
- selenium测试(Java)--多表单切换(十二)
采用下面的例子来编写用例 <!DOCTYPE html> <html> <head> <meta http-equiv="content-type& ...
- AOP(Aspect Oriented Programming),即面向切面编程
AOP AOP(Aspect Oriented Programming),即面向切面编程,可以说是OOP(Object Oriented Programming,面向对象编程)的补充和完善.OOP引入 ...
- 在 C++ 程序中只使用 const 常量而不使用宏常量
在 C++ 程序中只使用 const 常量而不使用宏常量,即 const 常量完 全取代宏常量. #include <iostream> /* run this program using ...
- 你是否有遇到过某个实体类字段(属性)过多的情况,不想每次点的话戳进来(C# 反射)
贴上一段代码: bureaucraticEntities apply = new bureaucraticEntities(); Type tapp= app.GetType(); Type ttmp ...
- java与c#的语法对比
1,命名空间与包 C#为了把实现相似功能的类组织在一起,引入了命名空间的概念(namespace) Java中与此对应的东西叫做包(package) 2,类的访问控制方面的不同 C#只有两种:publ ...
- C++类中静态成员函数
引述自<深入探索C++对象模型>2001:5:1版次,p-150 static member functions的主要特性就是它没有this指针,所以: 1.它不能直接存取其所在class ...
- Linux 快速删除大量小文件方法
进行以下两步操作即可: 1.第一步:创建空的文件夹: mkdir /tmp/blank 2.第二步:执行以下命令:rsync --delete-before -d /tmp/blank/ /home ...
- INSTALL_FAILED_INVALID_APK
在项目中无意中把APP只写成了 xxx 没有xxx.xxx.xxx 掉坑里了,找了好久,给大家提不醒
- iOS - UITableView滚动到指定的cell并且选中
UITableView //项目中遇到的 - (void)selectRowAtIndexPath:(nullable NSIndexPath *)indexPath animated:(BOOL)a ...