在/etc/init.d/目录下创建脚本

vim  /etc/init.d/nginx 

编写脚本内容:(其中下面2行需要根据情况自行修改)

nginxd=/opt/nginx/sbin/nginx
nginx_config=/opt/nginx/conf/nginx.conf

脚本下载链接:http://pan.baidu.com/s/1jGrK0Vs 密码:cxjb

更改脚本权限

chmod 777 /etc/init.d/nginx 

测试

service nginx start 或/etc/init.d/nginx start 

开机启动

chkconfig --list|grep nginx chkconfig --add nginx 
chkconfig --list|grep nginx nginx           0:关闭    1:关闭    2:关闭    3:关闭    4:关闭    5:关闭    6:关闭 # chkconfig --level 2345 nginx on # chkconfig --list|grep nginx nginx           0:关闭    1:关闭    2:启用    3:启用    4:启用    5:启用    6:关闭 

或将此命令加入到rc.local文件中,这样开机的时候nginx就默认启动了

vi /etc/rc.local 

加入一行 /etc/init.d/nginx start 保存并退出,下次重启会生效。

艺搜参考

http://www.imhdr.com/nginx/linux-centos-to-configure-nginx-mysql-php-fpm-redis-boot/

编写Nginx启停服务脚本的更多相关文章

  1. 编写Redis启停服务脚本

    脚本内容如下; fi   esac   exit$RETVAL 下载脚本:艺搜下载 将下载下来的脚本放在/etc/init.d/目录下 更改脚本权限 chmod 777 /etc/init.d/red ...

  2. nginx启停shell脚本

    #!/bin/bash # 编写 nginx 启动脚本 # 本脚本编写完成后,放置在/etc/init.d/目录下,就可以被 Linux 系统自动识别到该脚本 # 如果本脚本名为/etc/init.d ...

  3. shell启停服务脚本模板

    一. 启动脚本模板:符合幂等性 如果该服务已经启动,再次调用该脚本,不会报错,也就是说可以反复多次调用,另外启动成功返回 一个参数,提供给自动发布平台校验该服务是否启动 #!/bin/bash ins ...

  4. nginx 启停命令

    nginx 启停配置 #!/bin/sh # # nginx Startup script for nginx # # chkconfig: - 85 15 # processname: nginx ...

  5. Redis windows版本的启停bat脚本命令

    Reids windows版本安装 redis windows官网推荐:https://github.com/MicrosoftArchive/redis/releases 下载解压即可. 启停bat ...

  6. nginx启停脚本

    安装nginx时,源码包中未带官方的启动脚本,也就无法使用service nginxd start这种启动方式,查了下资料自己写了一个: #!/bin/bash #@version: #@author ...

  7. Nginx启停

    启动nginx /usr/local/nginx/nginx #不指定配置文件地址/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx. ...

  8. 编写使用systemctl启动服务脚本

    CentOS 7的服务systemctl脚本存放在:/usr/lib/systemd/,有系统(system)和用户(user)之分,像需要开机不登陆就能运行的程序,还是存在系统服务里吧,即:/usr ...

  9. MySQL - 启停服务

    Windows 环境 命令行方式 启动 MySQL 服务: net start mysql停止 MySQL 服务: net stop mysql 注:需要以管理员身份启动 cmd 后再执行上述命令. ...

随机推荐

  1. TreeView 类 事件

    名称 说明 AfterCheck 在选中树节点复选框后发生. AfterCollapse 在折叠树节点后发生. AfterExpand 在展开树节点后发生. AfterLabelEdit 在编辑树节点 ...

  2. Node.js mm131图片批量下载爬虫1.01 增加断点续传功能

    这里的断点续传不是文件下载时的断点续传,而是指在爬行页面时有时会遇到各种网络中断而从中断前的页面及其数据继续爬行的过程,这个过程和断点续传原理上相似故以此命名.我的具体做法是:在下载出现故障或是图片已 ...

  3. Office 如何下载网页的视频 JWPlayer的内嵌视频

    右击页面空白处,查看页面源代码 在里面搜索mp4或者swf,video,一般网页中的视频都是这些格式,仔细找一定能找到对应的地址 然后复制到迅雷下载即可

  4. js调试工具console方法详解

    一.显示信息的方法 最常用的console.log(),一般用来调试. console.log('hello'); console.info('信息'); console.error('错误'); c ...

  5. UVA 10168 Summation of Four Primes(数论)

    Summation of Four Primes Input: standard input Output: standard output Time Limit: 4 seconds Euler p ...

  6. struts2+jquery验证注冊用户是否存在

    注冊界面 register.jsp <%@ page language="java" contentType="text/html; charset=UTF-8&q ...

  7. 2 自己编写:AppDelegate,CCApplication,CCApplicationProtocol

    1 CCApplicationProtocol.h /* * CCApplicationProtocol.h * *  Created on: 2014年10月19日 *      Author: t ...

  8. sql jion

    A Visual Explanation of SQL Joins I thought Ligaya Turmelle's post on SQL joins was a great primer f ...

  9. MVC 强类型传值Model。和弱类型传值ViewData[&quot;&quot;]。及用EF进行增删查改(母版页的使用)

    <1> 控制器 </pre><pre name="code" class="csharp">using MvcTest.Mo ...

  10. struts2 Action向JSP传值方式

    1.通过属性getXXX()和setXXX()方式 Action类 public class Test { private String name; public String getName() { ...