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/ ...
随机推荐
- Lesson 2-3(字符串)
2.5 字符串 --- 字符串是不可变的. >>> str = "Hello world!" >>> str[-6:-1] = "py ...
- 成环的概率dp(初级) zoj 3329
原题地址:https://vjudge.net/problem/ZOJ-3329 题目大意: 有三个骰子,分别有k1,k2,k3个面,初始分数是0.第i骰子上的分数从1道ki.当掷三个骰子的点数分别为 ...
- Django-model
Model:数据库操作 创建数据库的表: django不能自动创建数据库,但能创建表 在web的models里定义生成表 在project的settings里设置app定义和数据库信息 步骤: 1.创 ...
- OpenCV-Python:轮廓
啥叫轮廓 轮廓是一系列相连的点组成的曲线,代表了物体的基本外形. 轮廓与边缘很相似,但轮廓是连续的,边缘并不全都连续,其实边缘主要是作为图像的特征使用,比如用边缘特征可以区分脸和手,而轮廓主要用来分析 ...
- 2018-2019-2 网络对抗技术 20165328 Exp5 MSF基础应用
目录 实验要求: 基础问题回答: 离实战还缺些什么技术或步骤? 实验内容: Exp5-1 主动攻击实践:实现ms08_067(失败) 实现ms17_010_eternalblue(成功) Exp5-2 ...
- 考勤输入导入OA平台与考勤统计报表导出功能源代码
注:以某某公司为例,每日签到时间为8点整 每日签退时间为17点30分 规则:公司签到签退时间在OA平台中可以视实际情况调整,当天有请假并通过工作流审批通过为有效,当天因公外出并通过工作流审批通过为 ...
- 使用Nginx+Lua实现waf
使用Nginx+Lua实现waf 技术内容来自:https://github.com/loveshell/ngx_lua_waf 软件包需求: 1 .Nginx兼容性[最后测试到1.13.6] [ro ...
- [转] JavaScript中in操作符(for..in)、Object.keys()和Object.getOwnPropertyNames()的区别
ECMAScript将对象的属性分为两种:数据属性和访问器属性.每一种属性内部都有一些特性,这里我们只关注对象属性的[[Enumerable]]特征,它表示是否通过 for-in 循环返回属性,也可以 ...
- canvas20181114
1. canvas 描边.填充.画线.闭合路径.非零环绕原则 <!DOCTYPE html> <html lang="en"> <head> & ...
- linux下mysql修改字符集
# 编辑/etc/my.cnfvim /etc/my.cnf # 在[mysqld]标签下添加下面内容default-storage-engine = innodbinnodb_file_per_ta ...