CentOS7+Nginx设置Systemctl restart nginx.service服务
centos 7上是用Systemd进行系统初始化的,Systemd 是 Linux 系统中最新的初始化系统(init),它主要的设计目标是克服 sysvinit 固有的缺点,提高系统的启动速度。关于Systemd的详情介绍在这里。
Systemd服务文件以.service结尾,比如现在要建立nginx为开机启动,如果用yum install命令安装的,yum命令会自动创建nginx.service文件,直接用命令
systemcel enable nginx.service
设置开机启动即可。
在这里我是用源码编译安装的,所以要手动创建nginx.service服务文件。
开机没有登陆情况下就能运行的程序,存在系统服务(system)里,即:
/lib/systemd/system/
1.在系统服务目录里创建nginx.service文件
vi /lib/systemd/system/nginx.service
编辑如下内容
[Unit]
Description=nginx
After=network.target [Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true [Install]
WantedBy=multi-user.target
[Unit]:服务的说明
Description:描述服务
After:描述服务类别
[Service]服务运行参数的设置
Type=forking是后台运行的形式
ExecStart为服务的具体运行命令
ExecReload为重启命令
ExecStop为停止命令
PrivateTmp=True表示给服务分配独立的临时空间
注意:[Service]的启动、重启、停止命令全部要求使用绝对路径
[Install]运行级别下服务安装的相关设置,可设置为多用户,即系统运行级别为3
保存退出。
2.设置开机启动
启动nginx服务
systemctl start nginx.service
设置开机自启动
systemctl enable nginx.service
停止开机自启动
systemctl disable nginx.service
查看服务当前状态
systemctl status nginx.service
重新启动服务
systemctl restart nginx.service
查看所有已启动的服务
systemctl list-units --type=service
原址:https://blog.csdn.net/qq_36441027/article/details/80636526
CentOS7+Nginx设置Systemctl restart nginx.service服务的更多相关文章
- 重启ssh服务出现Redirecting to /bin/systemctl restart sshd.service
转自:https://blog.csdn.net/caijunfen/article/details/70599138 CentOs 重启ssh服务的命令如下: # service sshd rest ...
- centos7也支持service命令启动服务吗,对于centos7 中的systemctl和旧的service命令的区别和联系
一.centos7也支持service命令启动服务吗 CentOS 7.0中一个最主要的改变,就是切换到了systemd.它用于替代红帽企业版Linux前任版本中的SysV和Upstart,对系统和服 ...
- Centos7下的systemctl命令与service和chkconfig
博主使用的操作系统是最新的CentOS 7,所以可能和网上一些老的博文有一定出入,那是因为版本更新的原因. 这里写图片描述1 service service命令用于对系统服务进行管理,比如启动(sta ...
- 安装和启动tftp-server服务器及可能出现Redirecting to /bin/systemctl restart xinetd.service问题的解决方式
安装和启动tftp-server服务器及可能出现Redirecting to /bin/systemctl restart xinetd.service问题的解决方式 1)首先,检查服务器已安装的tf ...
- 阿里云报错Redirecting to /bin/systemctl restart sshd.service
转:http://blog.csdn.net/caijunfen/article/details/70599138 云服务器 ECS Linux CentOS 7 下重启服务不再通过 service ...
- 【linux】CentOS 6 使用cron定时任务,报错:Redirecting to /bin/systemctl restart crond.service
在centos7上,执行cron定时任务的相关命令,反馈如下: 定时任务执行,反馈是: Redirecting to /bin/systemctl restart crond.service 原因: ...
- Linux Redirecting to /bin/systemctl restart iptables.service
方案 一 1.昨天碰到一个错误,linux下输入命令:service iptables restart时,总会报下面一个提示很简单,这句话的意思就是让你重定向到systemctl然后再启用,白话就是说 ...
- Redirecting to /bin/systemctl restart mysql. service Failed to restart mysql.service: Unit not found.
使用如下命令操作mysql即可: systemctl restart mysqld.service systemctl start mysqld.service systemctl stop mysq ...
- 把ngnix注册为linux服务 将Nginx设置为linux下的服务 并设置nginx开机启动
一.创建服务脚本 vim /etc/init.d/nginx 脚本内容如下 #! /bin/sh# chkconfig: - 85 15 PATH=/usr/local/nginx/sbin/ DES ...
随机推荐
- C# 将dll打包到程序中
本文告诉大家如何把 dll 打包到程序中.很多时候的 软件 在运行的时候需要包括很多 dll 或其他的文件,这样的软件在给其他小伙伴,就需要做一个压缩包,或者用安装软件.这样感觉不太好,所以本文告诉大 ...
- SQL脚本修改数据库名称
USE master; GO DECLARE @SQL VARCHAR(MAX); SET @SQL='' SELECT @SQL=@SQL+'; KILL '+RTRIM(SPID) FROM ma ...
- CSS学习笔记06 简单理解line-height
在制作页面的时候,经常会遇到文本图片需要居中的情况,这时候,只要设置下文本的line-height属性等于包裹该文本的元素的高度即可让文本居中显示了,先来看看这个现象. <!DOCTYPE ht ...
- JAVA设计模式详解(二)----------观察者模式
有一个模式可以帮助你的对象知悉现况,不会错过该对象感兴趣的事,对象甚至在运行时可以决定是否要继续被通知,如果一个对象状态的改变需要通知很多对这个对象关注的一系列对象,就可以使用观察者模式 .观察者模式 ...
- 《JavaScript DOM 编程艺术》读书笔记
<JS DOM 编程艺术>笔记 一. 三种节点 元素节点.文本节点.属性节点 二. 获取元素 1.document.getElementById 2.(element)document.g ...
- python内置函数每日一学 -- all()
all(iterable) 官方文档解释: Return True if all elements of the iterable are true (or if the iterable is em ...
- 前端hash路由基本原理,及代码的基本实现
路由就是指随着浏览器地址栏的变化,展示给用户的页面也不相同. 早期的路由都是后端实现的,直接根据 url 来 reload 页面,页面变得越来越复杂服务器端压力变大,随着 ajax 的出现,页面实现非 ...
- vue Element-UI 分页使用(1)
最近在使用Element-UI这套框架配合Vue来写前端页面.在用Element-UI来制作表格的时候,遇到了一些小问题,记录方便学习. 其中两个事件是关于切换当前页和切换显示的列表条数的.另外的属性 ...
- 深入解读《Gartner2017年商业智能和分析平台魔力象限报告》
文 | 帆软数据应用研究院 船长 2017年2月16日,Gartner发布了2017年BI商业智能和分析平台魔力象限报告,笔者这里进行一些解读,帮助大家更好了解市场状况和趋势. 一.几家欢笑几家愁 和 ...
- 树莓派 MPG视频硬件解码破解 Raspberry Pi Patch for MPEG-2, VC-1 license
Enable the Pi's hardware decoding of MPEG-2 and VC-1 MPEG2 patents have expired If you have start.e ...