网站首页
Java
站长
开源
框架
理论
JS
Linux
DB
服务器
NET
生活
软件
PHP
其他
您的位置:首页 > 软件 > Nginx配置到系统中
Nginx配置到系统中
2022-2-3    2307    0

Nginx("engine x")是一款是由俄罗斯的程序设计师Igor Sysoev所开发高性能的 Web和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器。


之前写过Nginx启动关闭重启用脚本实现:http://www.javacui.com/tool/609.html  ,下面是把Nginx服务注册到系统中,达到可以使用systemctl来管理的目的。


vim /usr/lib/systemd/system/nginx.service


编辑内容:

[Unit]
Description=nginx web service
Documentation=http://nginx.org/en/docs/
After=network.target

[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop
PrivateTmp=true

[Install]
WanteBy=default.target


通过命令来操作nginx:

systemctl start nginx
systemctl stop nginx
systemctl restart nginx
systemctl reload nginx
systemctl status nginx
systemctl enable nginx #开机启动
systemctl disable nginx #禁用开机启动


把nginx命令配置到系统中:

vim /etc/profile
# 在文件末尾添加内容:export PATH=$PATH:/usr/local/nginx/sbin
source /etc/profile


在任何目录都可以直接使用nginx命令

上一篇: Nginx解决跨域问题
下一篇: Nginx配置文件conf解释
发表评论:
您的网名:
个人主页:
编辑内容: