nginx开机启动
centos 7以上是用Systemd进行系统初始化的
Systemd服务文件以.service结尾,比如现在要建立nginx为开机启动,如果用yum install命令安装的,yum命令会自动创建nginx.service文件,直接用命令
#systemcel enable nginx.service
设置开机启动即可。
在这里我是用源码编译安装的,所以要手动创建nginx.service服务文件。
开机没有登陆情况下就能运行的程序,存在系统服务(system)里,即:
#cd /lib/systemd/system
#vi 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
设置开机启动:
#systemctl enable nginx.service
停止开机自启动:
#systemctl disable nginx.service
其它命令:
#systemctl start nginx.service
#systemctl status nginx.service
#systemctl restart nginx.service
#systemctl stop nginx.service
参考:
https://www.cnblogs.com/piscesLoveCc/p/5867900.html
nginx开机启动的更多相关文章
- CentOS下nginx+php的配置及nginx开机启动配置
关闭防火墙 (不然外链接是访问不了 apache) service iptables stop 关闭安全系统 SELinux( 不然报403 访问页面错误 ) 1.Nginx安装主要在于配置文件的修改 ...
- centos6.5 nginx开机启动
/etc/init.d/下添加nginxd文件,内容如下: #!/bin/bash # #chkconfig: - #description: Nginx is a World Wide Web se ...
- Centos7 Nginx开机启动
1.简易安装nginx: ./configure --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf ...
- 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 Nginx 开机启动
Centos 系统服务脚本目录: 用户(user) 用户登录后才能运行的程序,存在用户(user) /usr/lib/systemd/ 系统(system) 如需要开机没有登陆情况下就能运行的程序,存 ...
- [转]centos7.2 下 nginx 开机启动
1.在系统服务目录里创建nginx.service文件 vi /lib/systemd/system/nginx.service 内容如下 [Unit] Description=nginx After ...
- Linux上如何设置nginx开机启动
连接上linux后输入以下命令--vim /etc/init.d/nginx 然后在这个空文件写入下面内容: 保存好后,修改下该文件权限--chmod 777 /etc/init.d/nginx 然后 ...
- 把ngnix注册为linux服务 将Nginx设置为linux下的服务 并设置nginx开机启动
一.创建服务脚本 vim /etc/init.d/nginx 脚本内容如下 #! /bin/sh# chkconfig: - 85 15 PATH=/usr/local/nginx/sbin/ DES ...
- linux下安装nginx后开机启动篇
众所周知nginx安装后需要手动去启动,每次开机之后都要执行nginx的启动命令很蛋疼.那么我们来让nginx开机启动吧 1.先創建一個nginx文件把 [root@localhost ~]# vi ...
随机推荐
- 爬虫-day02-抓取和分析
###页面抓取### 1.urllib3 是一个功能强大且好用的HTTP客户端,弥补了Python标准库中的不足 安装: pip install urllib3 使用: imp ...
- MySQL 索引的增删查
查看索引: > SHOW INDEX FROM table_name; > SHOW KEYS FROM table_name; 删除索引: > DROP INDEX index ...
- cmake中添加-fPIC编译选项方法
合并openjpeg/soxr/vidstab/snappy等多个cmake库时,为了解决下述问题: relocation R_X86_64_32 against `.text' can not be ...
- sklearn错误
1.No module named 'sklearn.cross_validation' sklearn.cross_validation会报错,关键在于新版本的sklearn没有cross_vali ...
- 通过 phpmyadmin getshell
通过 phpmyadmin getshell general_log默认为关闭的,root权限开启后,general_log_file会保存所有的查询语句 可以开启general_log,然后设置g ...
- EChart 猜猜乐
http://m.bkbtcaicaile.hyl.life/index.html#/
- MyEclipse2015优化
< MyEclipse 2015优化七步法<亲测有效> > l 去除无需加载的模块 Window --> Preferences -->General --> ...
- Python的内置函数
python的内置函数一共有68个,下面将简单介绍各个函数的功能. abs() dict() help() min() setattr() all() dir() hex() next() slice ...
- Vue.js中记不住 的东西
给样式背景赋值: :style="{backgroundImage:'url(' + otherInfo.head_image + ')'}" <img :src=" ...
- GC roots
1.虚拟机栈(本地变量表)引用的对象 2.方法区静态属性引用的对象 3.方法区常量引用的对象 4.本地方法栈JNI(一般指naive方法)中引用的对象 常说的GC(Garbage Collecto ...