Centos7 Nginx开机启动
1.简易安装nginx:
./configure --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid
2.进入/usr/lib/systemd/system目录下,编写nginx.service文件:
[Unit]
Description=nginx - high performance web server
After=network.target remote-fs.target nss-lookup.target [Service]
Type=forking
ExecStart=/usr/local/nginx/nginx -c /usr/local/nginx/nginx.conf
ExecReload=/usr/local/nginx/nginx -s reload
ExecStop=/usr/local/nginx/nginx -s stop [Install]
WantedBy=multi-user.target
3.设置开机启动nginx.service服务:
systemctl enable nginx.service
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
4.执行步骤3后,会在/etc/systemd/system/multi-user.target.wants/目录下生成nginx.service的软链接,multi-user.target.wants目录对应2步骤的WantedBy制定的运行级别,此时可以执行相关命令操作nginx服务:
systemctl enable nginx.service 开机启动nginx服务
systemctl disable nginx.service 禁止开机启动nginx服务
systemctl is-enable nginx.service 查询是否开机启动nginx服务
systemctl start nginx.service 启动nginx服务
systemctl stop nginx.service 停止nginx服务
systemctl reload nginx.service 重新加载nginx服务
systemctl status nginx.service 查看nginx服务状态
5.服务文件格式:
[Unit]:服务的说明
Description:描述服务
After:描述服务类别 [Service]服务运行参数的设置
Type=forking是后台运行的形式
ExecStart为服务的具体运行命令
ExecReload为重启命令
ExecStop为停止命令
PrivateTmp=True表示给服务分配独立的临时空间
注意:[Service]的启动、重启、停止命令全部要求使用绝对路径 [Install]服务安装的相关设置,可设置为多用户
Centos7 Nginx开机启动的更多相关文章
- Centos7 Nginx 开机启动
Centos 系统服务脚本目录: 用户(user) 用户登录后才能运行的程序,存在用户(user) /usr/lib/systemd/ 系统(system) 如需要开机没有登陆情况下就能运行的程序,存 ...
- CentOS下nginx+php的配置及nginx开机启动配置
关闭防火墙 (不然外链接是访问不了 apache) service iptables stop 关闭安全系统 SELinux( 不然报403 访问页面错误 ) 1.Nginx安装主要在于配置文件的修改 ...
- centos7.2 下 nginx 开机启动
1.在系统服务目录里创建nginx.service文件 1 vi /lib/systemd/system/nginx.service 内容如下 1 2 3 4 5 6 7 8 9 10 11 12 1 ...
- [转]centos7.2 下 nginx 开机启动
1.在系统服务目录里创建nginx.service文件 vi /lib/systemd/system/nginx.service 内容如下 [Unit] Description=nginx After ...
- centos6.5 nginx开机启动
/etc/init.d/下添加nginxd文件,内容如下: #!/bin/bash # #chkconfig: - #description: Nginx is a World Wide Web se ...
- nginx开机启动
centos 7以上是用Systemd进行系统初始化的 Systemd服务文件以.service结尾,比如现在要建立nginx为开机启动,如果用yum install命令安装的,yum命令会自动创建n ...
- Centos7查询开机启动项服务
问题描述: 最近安装了zabbix设置了一些开机启动服务 例如:zabbix-server.service,httpd.service,mariadb.service,或者系统的firework.se ...
- centos7 管理开机启动:systemd
一.CentOS7 systemd 介绍 在 CentOS7 中,使用 systemd 来管理其他服务是否开机启动,systemctl 是 systemd 服务的命令行工具 [root@mysql ~ ...
- CentOS7 添加开机启动项
centos6 加入开机启动: vim /etc/rc.d/rc.local 注意命令不要出错,重启后生效 或者 centos 7 下: vim /lib/systemd/system/ ...
随机推荐
- UGUI中粒子特效与UI的遮挡问题
问题背景: 在做主线任务时发现完成任务后的特效显示穿透上面的UI层,不美观,策划不乐意了,抓紧解决下 解决思路: 首先讲下影响渲染顺序的因素: 能够影响渲染顺序的因素有:1.Camera Depth ...
- Calendar日历工具类
这个工具类有效的避免跨年的问题 先定义一个日期格式类型: SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:s ...
- Springboot 打jar包分离lib,配置文件正确方式
文章来源:https://my.oschina.net/xiaozhutefannao/blog/1932764 POM.xml <?xml version="1.0" en ...
- servlet九大内置对象和监听器
对象名称 类型 描述 作用域 request javax.servlet.ServletRequest 表示一次用户请求 Request response javax.servlet.SrvletRe ...
- 使用token做认证
对当前用户,使用base64加密token,再解密token,但是不如JWT加密安全 import time import base64 import hmac def generate_token( ...
- 分享:使用 TypeScript 编写的游戏代码
<上篇博客>我写出了我一直期望的 JavaScript 大型程序的开发模式,以及 TS(TypeScript) 的一些优势.博客完成之后,我又花了一天时间试用 TS,用它来重构之前编写的一 ...
- Sentry部署
前期准备 [root@Aaron ~]# uname -r 3.10.0-327.el7.x86_64 [root@Aaron ~]# uname -a Linux Aaron 3.10.0-327. ...
- golang channel string 信号乱码
原因golang代码编写是允许在同一个for select代码结构中使用相同的变量名,这样会造成运行时chan发送的内容出现乱码现象,乱码率大概在98%左右,所以这是一个坑,希望大家别重复踩坑.以下是 ...
- Selenium Webdriver点击事件失效问题
最近在用selenium webdriver时,遇到一个棘手的问题,点击事件有时候会失效,具体原因我也不知道是什么. 但是有两个解决办法,第一,在点击该标签前,先点击它的父标签,也就是点击两次. dr ...
- UOJ#290. 【ZJOI2017】仙人掌 仙人掌,Tarjan,计数,动态规划,树形dp,递推
原文链接https://www.cnblogs.com/zhouzhendong/p/UOJ290.html 题解 真是一道好题! 首先,如果不是仙人掌直接输出 0 . 否则,显然先把环上的边删光. ...