NGINX、PHP-FPM开机自动启动
NGINX SHELL脚本 放到/etc/init.d/下取名nginx
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse
# proxy and IMAP/POP3 proxy server
# processname: nginx
# chkconfig: 2345 90 91
# description: nginx web server
# processname: nginx
# config: /opt/nginx/conf/nginx.conf
# pidfile: /opt/nginx/nginx.pid # Source function library.
. /etc/init.d/functions # Source networking configuration.
. /etc/sysconfig/network if [ -f /etc/sysconfig/nginx ];then
. /etc/sysconfig/nginx
fi # Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0 nginx="/usr/local/nginx/sbin/nginx"
prog=$(basename $nginx) NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf" [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx lockfile=/var/lock/subsys/nginx start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
echo -n $"Starting $prog: "
daemon $nginx #-c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
} stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
killall -9 nginx
} restart() {
configtest || return $?
stop
sleep 1
start
} reload() {
configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
} force_reload() {
restart
} configtest() {
$nginx -t #-c $NGINX_CONF_FILE
} rh_status() {
status $prog
} rh_status_q() {
rh_status >/dev/null 2>&1
} case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart)
$1
;;
test)
configtest
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|test}"
exit 2
esac
PHP-FPM SHELL脚本 放到/etc/init.d/下 取名php-fpm
#!/bin/bash
# php-fpm startup script for the php-fpm
# php-fpm version:5.5.0-alpha6
# chkconfig: - 85 15
# description: php-fpm is very good
# processname: php-fpm
# pidfile: /var/run/php-fpm.pid
# config: /usr/local/php/etc/php-fpm.conf php_command=/usr/local/php/sbin/php-fom
php_config=/usr/local/php/etc/php-fpm.conf
php_pid=/usr/local/php/var/run/php-fpm.pid
RETVAL=0
prog="php-fpm" #start function
php_fpm_start() {
/usr/local/php/sbin/php-fpm
} start(){
if [ -e $php_pid ]
then
echo "php-fpm already start..."
exit 1
fi
php_fpm_start
} stop(){
if [ -e $php_pid ]
then
parent_pid=`cat $php_pid`
all_pid=`ps -ef | grep php-fpm | awk '{if('$parent_pid' == $3){print $2}}'`
for pid in $all_pid
do
kill $pid
done
kill $parent_pid
fi
exit 1
} restart(){
stop
start
} # See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status $prog
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|status}"
exit 1
esac
exit $RETVAL
后续处理:
## 添加执行权限
chmod a+x /etc/init.d/nginx #755
chmod a+x /etc/init.d/php-fpm #755 ## 加入服务
chkconfig --add nginx
chkconfig --add php-fpm ## 开机自启
chkconfig nginx on
chkconfig php-fpm on
NGINX、PHP-FPM开机自动启动的更多相关文章
- nginx设置成开机自动启动服务
1.nginx的安装目录 /usr/local/nginx 启动nginx cd /usr/local/nginx/sbin./nginx 更改配置重启nginxcd /usr/local/nginx ...
- Window下将nginx配置为开机自动启动
前两天看到公司window服务器上面有个nginx在跑,重启服务器后没有自动启动,需要手动运行nginx,甚是麻烦呀 上网找了一下关于将nginx配置为系统服务并且开机自动启动的解决方案,这里mark ...
- nginx linux 下开机自动启动
这里使用的是编写shell脚本的方式来处理 vi /etc/init.d/nginx (输入下面的代码) #!/bin/bash# nginx Startup script for the Ngin ...
- nginx + fastDFS 设置开机自动启动
由于在服务器上有太多的软件 不可能每次启动都要重新启动服务吧(每晚断电...必须重启电脑) vim /etc/rc.d/rc.local 添加下列脚本 /usr/bin/fdfs_trackerd / ...
- centos将nginx服务设置为开机自动启动
centos将nginx服务设置为开机自动启动 1.在/etc/init.d下创建文件nginx 发现原来就有并且配置就是默认的,而且是正确的 命令为: vim /etc/init.d/nginx 需 ...
- Nginx设置成服务并开机自动启动
在/etc/init.d下创建文件nginx [root@localhost ~]# vim /etc/init.d/nginx 其内容参考nginx官方文档 需要注意的配置: nginx=”/usr ...
- php-fpm开机自动启动脚本其实源码包里边就有
网上有各种版本的php-fpm开机自动启动脚本, 其实你编译后源目录已经生成自动脚本.不用做任何修改即用.cp {php-5.5.x-source-dir}/sapi/fpm/init.d.php-f ...
- [转] ubuntu16.04添加系统 service, 并设置开机自动启动
转:https://www.jianshu.com/p/1958878646bd 1. 创建pfly.service文件 2. 执行 systemctl daemon-reload 3. 执行 sy ...
- linux启动SSH及开机自动启动
本文地址 分享提纲: 1.查看是否启动 2. 设置自动启动 1.[查看是否启动] 启动SSH服务 “/etc/init.d/sshd start”.然后用netstat -antulp | grep ...
随机推荐
- 常见开发需求之前端利器webstorm中的git和快捷键
需求 前端开发中我们最常用的一般是webstorm.hbuilder和sublime,因为以前使用过一段时间eclipse所以我对webstorm的感觉比较良好,再加上以前使用hbuilder维护 ...
- Gym100947E || codeforces 559c 组合数取模
E - Qwerty78 Trip Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u S ...
- ORACLE操作列
一.下面介绍oracle数据库操作列的CURD操作 --学生表 STUDENT CREATE TABLE STUDENT( ID NUMBER(18) NOT NULL, NAME VARCHAR2( ...
- Flask 教程
官方文档 推荐教程 环境 pip install virtualenv cd proj_fold virtualenv venv . venv/bin/activate for *unix or ve ...
- JAVA学习笔记之static——2016.3.10
static关键字 作用:修饰符,用于修饰成员<成员产量,成员方法> 1'被修饰的成员产量只有一份. 2'被修饰后的成员多了一种方式的访问,除了可以对象调用外,还可以被 ...
- 第三方登录分享功能-ShareSDK for iOS适配问题记录
最近app里需要添加第三方授权登陆和分享的功能,选择了ShareSDK,参考了ShareSDK文档对该SDK进行了适配,但遇到了一些问题 1.问题:分享功能点击不跳转 原因:适配iOS9添加白名单 ...
- Ubuntu 16.04 install 搜狗输入法
1.#先添加以下源 sudo add-apt-repository ppa:fcitx-team/nightly 2.#添加源之后需要更新一下系统 sudo apt-get update 3.#开始安 ...
- CSV格式数据如何导入MySQL?
经常有客户咨询如何将CSV文件导入到MySQL数据库中,特写此文介绍一种方便.快捷的方法. 我们要使用的辅助工具是著名的MySQL管理软件:Navicat for MySQL 1)我准备了一个字符编码 ...
- 客户端JavaScript-如何执行
客户端JavaScript程序有四部分:内联脚本.HTML事件处理程序.URL中的JavaScript.外联脚本:所有这些单独的代码共用同一个全局Window对象,它们可以看到相同的Document对 ...
- 不能用con作为类名
A class file was not written. The project may be inconsistent, if so try refreshing this project and ...