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/ ...
随机推荐
- spring-cloud-feign负载均衡组件
Feign简介: Feign是一个声明式的Web服务客户端,使用Feign可使得Web服务客户端的写入更加方便.它具有可插拔注释支持,包括Feign注解和JAX-RS注解.Feign还支持可插拔编码器 ...
- Web开发疑难问题解决方案-(最近更新:2018-11-29)
这篇文章用来记录Web(包括PC和移动端)开发过程中遇到的一些疑难问题的解决方案. P1. '1像素边框'问题 P2.只读输入框在ios上的莫名表现 P3.自适应高度的textarea P4. CSS ...
- Spring Cloud 快速入门
Spring Cloud快速入门 代码地址: https://gitee.com/gloryxu/spring-cloud-test EureKa:服务注册中心 添加依赖 <dependenc ...
- 身份证号验证js程序
最近注册一个网站,居然让我输入个人身份证号,身份证号是个人信息,怎么能告诉你呢? 输入正确的身份证号没有任何问题. 我就仅仅改了最后一位,就告诉我身份证号不对,你是怎么知道的呢?所以,搜了下身份证号的 ...
- Django--post提交表单内容
本节目标:①.提交表单内容②.通过客户端提交表单新增一篇文章③.通过Django的forms组件来完成新增一篇文章 =======提交表单内容======== 1.前端html:login.html ...
- ConcurrentHashmap详解以及在JDK1.8的更新
因为hashmap本身是非线程安全的,如果多线程对hashmap进行put操作的话,就会导致死循环等现象.ConcurrentHashMap主要就是为了应对hashmap在并发环境下不安全而诞生的,C ...
- Linux磁盘和文件系统管理
1.检测并确认新硬盘 挂载好新的硬盘设备并启动主机后,Linux系统会自动检测并加载该硬盘,无须额外安装驱动.执行“fdisk -l”命令即可查看,确认新增硬盘的设备名称和位置.作用:列出当前系统中所 ...
- python控制语句---循环结构语句
这次主要把循环结构的控制语句补上,主要包含while.for.continue.break.循环嵌套.主要写一些基本的认识以及包含的一些实例.当只有唯一路径且只跑一次的时候选择上一节中的选择结构语句就 ...
- c++/qt的数据序列化和反序列化
序列化以及反序列化的实现 struct Body { double weight; double height; }; //结构体 struct People { int age; Body dBod ...
- mongodbwindows安装过程附带安装包百度云
1.mongodb安装包链接 链接:https://pan.baidu.com/s/1bxZ2oV-iJEs7RoH5kN6jVg 密码:ajuj 2.配置准备,创建文件夹及文件: 目录为: \ ...