nginx centos 服务开机启动设置实例详解_nginx

nginx centos 服务开机启动设置

建立服务文件

以nginx 为例

vim /lib/systemd/system/nginx.service 

在nginx.service 中插入一下内容

[Unit]
Description=nginx
After=network.target 

[Service]
Type=forking
ExecStart= 服务启动命令
ExecReload= 服务重启命令
ExecStop=服务停止命令
PrivateTmp=true 

[Install]
WantedBy=multi-user.target 

[Unit]:服务的说明
Description:描述服务
After:描述服务类别
[Service]服务运行参数的设置
Type=forking是后台运行的形式
ExecStart为服务的具体运行命令
ExecReload为重启命令
ExecStop为停止命令
PrivateTmp=True表示给服务分配独立的临时空间
注意:[Service]的启动、重启、停止命令全部要求使用绝对路径

以754的权限保存在目录:/lib/systemd/system 

设置开机自启动:

systemctl enable nginx.service

相关命令

功能                                       cnetos7以前                                          cnetos7
显示所有已启动的服务            chkconfig --list                 systemctl list-units --type=service

启动某服务       service nginx start systemctl             start nginx.service 或 systemctl start nginx

停止某服务       service nginx stop systemctl             stop nginx.service 或 systemctl stop nginx

重启某服务       service nginx restart                    systemctl restart nginx.service 或 systemctl restart nginx

使某服务自动启动     chkconfig --level 3 nginx  on       systemctl enable nginx.service 或 systemctl enable nginx

使某服务不自动启动     chkconfig --level 3 nginx off    systemctl disable nginx.service 或 systemctl disable nginx

检查服务状态       service nginx status                 systemctl is-active nginx.service (仅显示是否)Activesystemctl status nginx.service (服务详细信息)

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索centos
, nginx
, 开机启动
服务详细介绍
nginx实例详解、nginx实例详解 login、centos nginx开机启动、centos7开机启动nginx、centos nginx 安装,以便于您获取更多的相关知识。

时间: 2024-07-29 01:28:49

nginx centos 服务开机启动设置实例详解_nginx的相关文章

nginx下支持PATH_INFO的方法实例详解_nginx

本文实例分析了nginx下支持PATH_INFO的方法.分享给大家供大家参考,具体如下: 要想让nginx支持PATH_INFO,首先需要知道什么是pathinfo,为什么要用pathinfo? pathinfo不是nginx的功能,pathinfo是php的功能. php中有两个pathinfo,一个是环境变量$_SERVER['PATH_INFO']:另一个是pathinfo函数,pathinfo() 函数以数组的形式返回文件路径的信息;. nginx能做的只是对$_SERVER['PATH

CentOS 开机启动自定义脚本详解及实现_Linux

CentOS 开机启动自定义脚本 有些时候我们需要在服务器里设置一个脚本,让他一开机就自己启动.方法如下: cd /etc/init.d vi youshell.sh #将youshell.sh修改为你自己的脚本名 编写自己的脚本后保存退出. 在编写脚本的时候,请先加入以***释 #add for chkconfig  #chkconfig: #description:  #关于脚本的简短描述  #processname:  #第一个进程名,后边设置自启动的时候会用到 说明: 2345是指脚本的

Symfony2框架创建项目与模板设置实例详解_php实例

本文实例讲述了Symfony2框架创建项目与模板设置的方法.分享给大家供大家参考,具体如下: 环境准备与概览 习惯于在windows使用netbean编辑器并使用virtualbox虚拟centos系统, 预将nginx+php-fpm+mysql,  当然apache也是不错的选择,   使用http://symfony在windows与centos上作为开发域名. 一.下载与环境设置 1. 如何于centos上面建立开发环境不再详述, 当然也可以在windows上面建立开发环境. 2. 关于

linux开机自启动设置inittab详解

linux下的/etc/inittab中的英文解释: This file describes how the INIT process should set up  the system in a certain run-level.The inittab file describes which processes are started  at  bootup  and      during  normal operation. 通俗的说就是控制linux启动时的一些程序及级别. run-

Linux下重启oracle服务及监听器和实例详解_Linux

一.在Linux下重启Oracle数据库及监听器: 方法1: 用root以ssh登录到linux,打开终端输入以下命令: cd $ORACLE_HOME #进入到oracle的安装目录 dbstart #重启服务器 lsnrctl start #重启监听器 cd $ORACLE_HOME #进入到oracle的安装目录 dbstart #重启服务器 lsnrctl start #重启监听器 ----------------------------------- 方法2: Sql代码 cd $OR

用PHP的socket实现客户端到服务端的通信实例详解

一.server.php服务端: <?php error_reporting(E_ALL); set_time_limit(0); ob_implicit_flush(); //本地IP $address = 'localhost'; //设置用111端口进行通信 $port = 111; //创建SOCKET if (($sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) < 0) { echo "socket创建失败原因 &q

nginx下wordpress子目录伪静态设置步骤详解

网站访问目录为http://show.abc.com/ ,但是wordpress是装在他下面的manage目录中的,所以访问到的首页也该是http://show.abc.com/manage/ 而wordpress默认访问文章的URL是http://show.abc.com/manage/?p=12 的形式,需要做伪静态使文章访问形式为http://show.abc.com/manage/12 在nginx中配置如下: server { listen  80; server_name     s

Nginx中图片防盗链设置方法详解

由于有时候一些其他网站会调用本站的图片,nginx本身是可以屏蔽其他网站调用本站图片,方式如下: 根据后缀: location ~ \.(gif|jpg|png|swf|flv|bmp)$ {     valid_referers none blocked *. 111cn.net;     if ($invalid_referer) {     return 404; } } 根据目录:  location /images/ {   root /web/site/www/;   valid_r

CenterOS 中安装Redis及开机启动设置详解_Linux

CenterOS 中安装Redis及开机启动设置详解 从官方下载最新Redis进行安装,官网地址:http://redis.io/download $ wget http://download.redis.io/releases/redis-3.2.3.tar.gz $ tar xzf redis-3.2.3.tar.gz $ cd redis-3.2.3 $ make $ make install Redis启动 RedisServer /path/to/redis.conf Redis关闭(