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/ ...
随机推荐
- 使用requests+pyquery爬取dd373地下城跨五最新商品信息
废话不多说直接上代码: 可以使用openpyel库对爬取的信息写入Execl表格中代码我就不上传了 import requests from urllib.parse import urlencode ...
- python的pandas库学习笔记
导入: import pandas as pd from pandas import Series,DataFrame 1.两个主要数据结构:Series和DataFrame (1)Series是一种 ...
- shell脚本之不同系统上ftp交互使用
场景:当公司将有文件要自动将ubuntu系统的文件要上传到windows上面,或者windows上的文件要下载到ubuntu上面,尤其是像什么日志啊,编译结果啊,测试结果啊等等,做个备份或者做分析处理 ...
- Swift 编译时间优化
在Xcode中直接看到编译项目的时间 step1:关闭Xcode step2:打开终端执行defaults write com.apple.dt.Xcode ShowBuildOperationDur ...
- mysql免解压版的配置
很多朋友在安装mysq解压版l时出现: “mysql 服务无法启动 服务没报告任何错误” 以前我安装时也是遇到这样的问题: 其实mysql在5.6后就没有了data目录,很多朋友按照以前的版本安装会去 ...
- python正则表达式判断素数【厉害了】
参考: https://www.cnblogs.com/imjustice/p/check_prime_by_using_regular_expression.html for i in range( ...
- pwn学习之一
刚刚开始学习pwn,记录一下自己学习的过程. 今天完成了第一道pwn题目的解答,做的题目是2017年TSCTF的bad egg,通过这道题学习到了一种getshell的方法:通过在大小不够存储shel ...
- 微服务框架——SpringCloud
1.SpringCloud微服务框架 a.概念:SpringCloud是基于SpringBoot的微服务框架 b.五大神兽:Eureka(服务发现).Ribbon(客服端负载均衡).Hystrix(断 ...
- mpvue中使用wxParse,解析a标签跳转问题
安装:npm i mpvue-wxparse js:import wxparse from "mpvue-wxparse"; css:@import url('~mpvue-wxp ...
- tensorflow 使用 2 Felch ,Feed
Felch ::在会话里可以执行多个 op , import tensorflow as tf input1 = tf.constant(3.0) input2 = tf.constant(2.0) ...