centos nginx,php添加到Service
SHELL脚本:
nginx
vim /etc/init.d/nginx
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemin
#
# chkconfig: -
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /usr/local/nginx/conf/nginx.conf
# pidfile: /usr/local/nginx/logs/nginx.pid # Source function library.
. /etc/rc.d/init.d/functions # Source networking configuration.
. /etc/sysconfig/network # Check that networking is up.
[ "$NETWORKING" = "no" ] && exit nginx="/usr/sbin/nginx"
prog=$(basename $nginx) NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf" lockfile=/var/lock/subsys/nginx start() {
[ -x $nginx ] || exit
[ -f $NGINX_CONF_FILE ] || exit
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq ] && touch $lockfile
return $retval
} stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq ] && rm -f $lockfile
return $retval
} restart() {
configtest || return $?
stop
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 >&
} case "$1" in
start)
rh_status_q && exit
$
;;
stop)
rh_status_q || exit
$
;;
restart|configtest)
$
;;
reload)
rh_status_q || exit
$
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit
esac
运行命令:
sudo chmod +x /etc/init.d/nginx
sudo /sbin/chkconfig nginx on
sudo /sbin/chkconfig --list nginx
nginx :off :off :on :on :on :on :off
php-fpm脚本
vim /etc/init.d/php-fpm
#!/bin/bash
# php-fpm startup script for the php-fpm
# php-fpm version:5.5.-alpha6
# chkconfig: -
# 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-5.3/sbin/php-fom
php_config=/usr/local/php-5.3/etc/php-fpm.conf
php_pid=/usr/local/php-5.3/var/run/php-fpm.pid
RETVAL=
prog="php-fpm" #start function
php_fpm_start() {
/usr/local/php-5.3/sbin/php-fpm
} start(){
if [ -e $php_pid ]
then
echo "php-fpm already start..."
exit
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
} 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
esac
exit $RETVAL
运行命令:
sudo chmod +x /etc/init.d/php-fpm
sudo /sbin/chkconfig php-fpm on
sudo /sbin/chkconfig --list php-fpm
nginx 0:off 1:off 2:on 3:on 4:on 5:on 6:off
centos nginx,php添加到Service的更多相关文章
- cenos 安装nginx并添加到service
系统平台:CentOS release 6.6 (Final) 64位. 一.安装编译工具及库文件 yum -y install make zlib zlib-devel gcc-c++ libtoo ...
- CentOS6.5 下在Nginx中添加SSL证书以支持HTTPS协议访问
参考文献: 1. NginxV1.8.0安装与配置 2. CentOS下在Nginx中添加SSL证书以支持HTTPS协议访问 3. nginx配置ssl证书的方法 4.nginx强制使用https访问 ...
- 编译nginx平滑添加stream模块
1.操作背景 操作系统版本:CentOS Linux release (Core) nginx版本:1.13.4 nginx从1.9.0版本开始,新增了ngx_stream_core_module模块 ...
- Cacti监控服务器配置教程(基于CentOS+Nginx+MySQL+PHP环境搭建)
Cacti监控服务器配置教程(基于CentOS+Nginx+MySQL+PHP环境搭建) 具体案例:局域网内有两台主机,一台Linux.一台Windows,现在需要配置一台Cacti监控服务器对这两台 ...
- 把Nginx加为系统服务(service nginx start/stop/restart)
1.编写脚本,名为nginx #!/bin/sh # # nginx - this script starts and stops the nginx daemon # # chkconfig: - ...
- Linux centos nginx下载安装初步
下载源码包解压编译 1.下载 # wget http://nginx.org/download/nginx-1.9.9.tar.gz 2.解压 # tar xvf nginx-1.9.9.tar.gz ...
- 1分钟完美安装最新CentOS+Nginx+PHP-FPM+MySQL
PHP 5.3.1 MySQL 5.0.89 Nginx 0.8.33 或 0.7.65 (可选) 现在,我们可以快速全自动搞定 CentOS + Nginx + PHP-FPM + MySQL 的安 ...
- Linux 搭建Nginx并添加配置 SSL 证书
1. 安装准备 1.1 gcc安装 安装 nginx 需要先将官网下载的源码进行编译,编译依赖 gcc 环境,如果没有 gcc 环境,则需要安装: [root@nginx ~]# yum -y i ...
- 在阿里云服务器上配置CentOS+Nginx+Python+Flask环境
在阿里云服务器上配置CentOS+Nginx+Python+Flask环境 项目运行环境 阿里云(单核CPU, 1G内存, Ubuntu 14.04 x64 带宽1Mbps), 具体购买和ssh连接阿 ...
随机推荐
- Win7 安装.net framework 4.0 失败
Win7 安装.net framework 4.0 失败,错误HRESULT 0xc8000222解决办法 单独安装.net framework 4.0,结果还是失败,出现HRESULT 0xc800 ...
- Linux下DNS服务器的基本搭建
技术交流群:286866978 安装与配置 1. 装载光驱 2. 卸载光驱 3. 将安装包放在合适的文件夹并解压(有的更换光盘需要重新装载) 4. 安装 5. 重定向配置文件 6. 配置named.c ...
- Server.UrlEncode、HttpUtility.UrlDecode的区别
Server.UrlEncode.HttpUtility.UrlDecode的区别 在对URL进行编码时,该用哪一个?这两都使用上有什么区别吗? 测试: string file="文件上(传 ...
- UI3_UIViewController生命周期
// // SecondViewController.h // UI3_UIViewController生命周期 // // Created by zhangxueming on 15/7/2. // ...
- (转)Yale CAS + .net Client 实现 SSO(4)
第一部分:安装配置 Tomcat 第二部分:安装配置 CAS 第三部分:实现 ASP.NET WebForm Client 第四部分:实现基于数据库的身份验证 1.下载 Microsoft JDBC ...
- ionic中的生命周期函数
//ionic中的生命周期函数 onPageLoaded(){ //page初始化时 console.log("page 1 : page loaded"); } //在这里可以做 ...
- POJ 2407 Relatives
Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 13920 Accepted: 6965 Description Give ...
- Android app version code and name
android:versionCode和android:versionName 区别 Android的版本可以在androidmainfest.xml中定义, 主要有android:version ...
- 自制小工具监控wcf服务是否正常
由于项目中有2个使用netTcpBinding的wcf服务经常出现无法提供服务的问题,一直找原因也找不到导致影响严重,更换InstanceContextMode和ConcurrencyMode配置也不 ...
- gulp插件
gulp是趋势 gulp完全开发指南 => 快来换掉你的Grunt吧 gulp的工作流程:文件流--文件流--文件流......因为grunt操作会创建临时文件,会有频繁的IO操作,而gulp使 ...