zoukankan      html  css  js  c++  java
  • CentOS 7 配置nginx的service 脚本例子

    摘要: 在CentOS 7下配置nginx为系统服务

    在CentOS 7中对用户安装的应用服务设置为系统服务,比CentOS 6方便很多,下面以配置nginx为系统服务为例子进行说明。

    本例中的nginx采用源码编译方式进行安装,安装位置在/usr/local/nginx。要配置nginx为系统服务,需要有nginx.service文件,执行如下操作,编写service脚本。

    vim /usr/lib/systemd/system/nginx.service
    #nginx.service内容
    [Unit]
    Description=nginx - high performance web server
    Documentation=http://nginx.org/en/docs
    After=network.target remote-fs.target nss-lookup.target
    
    [Service]
    Type=forking
    PIDFile=/usr/local/nginx/nginx.pid
    ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
    ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
    ExecReload=/bin/kill -s HUP $MAINPID
    ExecStop=/bin/kill -s QUIT $MAINPID
    PrivateTmp=true
    
    [Install]
    WantedBy=multi-user.target
    #赋予脚本执行权限
    chmod +x /usr/lib/systemd/system/nginx.service
    #设置nginx.service为系统服务
    systemctl enable nginx.service
    
    ##通过系统服务操作nginx
    systemctl start nginx.service
    systemctl reload nginx.service
    systemctl restart nginx.service
    systemctl stop nginx.service



  • 相关阅读:
    036 Python进阶小结
    035 异常处理
    033 数据类型分类
    034 Python深浅拷贝
    032 集合类型内置方法
    031 字典类型内置方法
    XML删除节点
    追加XML
    XML文档的读、写
    XML文档的创建
  • 原文地址:https://www.cnblogs.com/jzy996492849/p/7150712.html
Copyright © 2011-2022 走看看