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 ...
随机推荐
- Docker学习链接
Docker安装篇 1>.Windows Docker 安装
- 【JVM】5、JVM内存管理机制
转自:http://blog.csdn.net/lengyuhong/article/details/5953544 近期看了看Java内存泄露的一些案例,跟原来的几个哥们讨论了一下,深入研究发现JV ...
- HDU3440(差分约束)
House Man Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total S ...
- 【 js 基础 】【读书笔记】关于this
this 关键字是 Javascript 中很特别的一个关键字,被自动定义在所有函数的作用域中.this提供了一种更优雅的方式隐式“传递”一个对象的引用.今天就来说说 this 的指向问题. this ...
- maven插件 按配置加载不同环境配置文件进行打包(maven-war-plugin)
1.配置多种不同环境 如(本地local,开发dev,测试test 环境等) <profiles> <profile> <id>local</id> & ...
- stylus常用写法
带参数 border-radius(val) -webkit-border-radius: val -moz-border-radius: val border-radius: val button ...
- 过滤器(Filter)与拦截器(Interceptor)的区别
1 .拦截器是基于java的反射机制的,而过滤器是基于函数回调. 2 .拦截器不依赖与servlet容器,过滤器依赖与servlet容器. 3 .拦截器只能对action请求起作用,而过滤器则可以对几 ...
- 在ActiveReports页面报表中显示Google地图
有些报表需求中需要我们显示国家.城市等地址信息,在报表中添加地图信息会让报表给最终用户代码更多有效信息. 在报表中可以将地图作为图片添加进来,当一个图片显示在报表中时,该图片必须存放到本地计算机或者服 ...
- SublimeText3常用插件及快捷键总结
SublimeText可谓是前端工程师的代码编辑神器,自从用上它以后一直爱不释手,特别是它强大的插件功能,简直要逆天了.网上也有很多关于SublimeText3的各种插件介绍,其插件功能之多,让人眼花 ...
- Google Play内购测试
Google Play内购测试 最近项目做海外版本,接入Google wallet支付后,测试验证比较繁琐,故记录一下. Google wallet支付方式接入完成后,需要按照如下步骤设置,才可以进行 ...