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的更多相关文章

  1. cenos 安装nginx并添加到service

    系统平台:CentOS release 6.6 (Final) 64位. 一.安装编译工具及库文件 yum -y install make zlib zlib-devel gcc-c++ libtoo ...

  2. CentOS6.5 下在Nginx中添加SSL证书以支持HTTPS协议访问

    参考文献: 1. NginxV1.8.0安装与配置 2. CentOS下在Nginx中添加SSL证书以支持HTTPS协议访问 3. nginx配置ssl证书的方法 4.nginx强制使用https访问 ...

  3. 编译nginx平滑添加stream模块

    1.操作背景 操作系统版本:CentOS Linux release (Core) nginx版本:1.13.4 nginx从1.9.0版本开始,新增了ngx_stream_core_module模块 ...

  4. Cacti监控服务器配置教程(基于CentOS+Nginx+MySQL+PHP环境搭建)

    Cacti监控服务器配置教程(基于CentOS+Nginx+MySQL+PHP环境搭建) 具体案例:局域网内有两台主机,一台Linux.一台Windows,现在需要配置一台Cacti监控服务器对这两台 ...

  5. 把Nginx加为系统服务(service nginx start/stop/restart)

    1.编写脚本,名为nginx #!/bin/sh # # nginx - this script starts and stops the nginx daemon # # chkconfig: - ...

  6. Linux centos nginx下载安装初步

    下载源码包解压编译 1.下载 # wget http://nginx.org/download/nginx-1.9.9.tar.gz 2.解压 # tar xvf nginx-1.9.9.tar.gz ...

  7. 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 的安 ...

  8. Linux 搭建Nginx并添加配置 SSL 证书

    1. 安装准备   1.1 gcc安装 安装 nginx 需要先将官网下载的源码进行编译,编译依赖 gcc 环境,如果没有 gcc 环境,则需要安装: [root@nginx ~]# yum -y i ...

  9. 在阿里云服务器上配置CentOS+Nginx+Python+Flask环境

    在阿里云服务器上配置CentOS+Nginx+Python+Flask环境 项目运行环境 阿里云(单核CPU, 1G内存, Ubuntu 14.04 x64 带宽1Mbps), 具体购买和ssh连接阿 ...

随机推荐

  1. iOS UIView简单缩放动画

    @interface ViewController () { UIView *animationView; UIButton *button; CGPoint animationPoint; } @e ...

  2. 查询sql 并且读取

    //显示地址 //VBSBegin // Set obj = GetObject("winmgmts:\\.\root\cimv2") // Set IPConfigSet = o ...

  3. table表格实现点击修改 PHP同步数据库 排序

    最近几天在做一个网站,牵扯到一个导航管理的功能!领导说不用作,可是由于自己自作主张,搞了1天的功能.领导说这个导航管理就是不用做!容易牵扯出好多问题来!估摸是客户小的原因! 没办法就把我1天的劳动荒废 ...

  4. C#中数组、ArrayList和List<T>三者的发展历程

    在C#中数组,ArrayList,List使我们用的最多的类型之一.他们共同的作用都是能够存储一组对象. 那么问题来了: (1)为什么要有三个一样作用的东西呢?他们都很完美吗? (2)谁先出生,又是因 ...

  5. UI布局

    1,初始化控件一般在onCreate()中完成,由于构造器中尚未完成控件加载,不能在其内初始化控件. 2,Activity子类必须含有无参构造.Intent.startActivity()方法调用的是 ...

  6. Codevs 1092 不高兴的津津

    时间限制: 1 s   空间限制: 128000 KB   题目等级 : 白银 Silver 题目描述 Description 津津上初中了.妈妈认为津津应该更加用功学习,所以津津除了上学之外,还要参 ...

  7. age

    #include<iostream> #include<math.h> #define pi 3.14 using namespace std; int main() { in ...

  8. Linux命令行提示符设置

    我们使用Linux系统时接触最多的是它的命令行窗口,很多时候我们都需要在命令行上输入命令,在输入的命令前都会有提示符,一般系统默认的提示符形式是:[username@host 工作目录]$. 其实,我 ...

  9. PCB参数计算神器-Saturn PCB Design Toolkit下载及安装指南

    进行PCB设计,特别是高频高速设计时,难免会涉及到PCB相关参数的计算及设置,如:VIA的过流能力,VIA的寄生电容.阻抗等,导线的载流能力,两相互耦合信号线间的串扰,波长等参数. 这里向大家介绍一款 ...

  10. 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换算法

    $x_pi = 3.14159265358979324 * 3000.0 / 180.0; //火星坐标系 (GCJ-02)转百度坐标系 (BD-09)算法 function bd_encrypt($ ...