Nginx的语法
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| nginx version: nginx/1.16.1 Usage: nginx [-?hvVtTq] [-s signal] [-c filename] [-p prefix] [-g directives]
Options: -?,-h : 帮助并退出 -v : 显示版本号并退出 -V : 显示版本号和配置选项并退出 -t : 测试配置文件并退出 -T : 测试配置文件,配置文件的详细配置内容并退出 -q : 在配置测试时,抑制正确信息输出 -s signal : 向主进程发送信号: stop, quit, reopen, reload -p prefix : 设置加载配置文件路径 nginx.conf (default: /etc/nginx/) -c filename : 设置加载指定配置文件 (default: /etc/nginx/nginx.conf) -g directives : 设置配置文件之外的全局指令
|
Nginx的常用指令
1 2 3 4 5
| nginx nginx -s stop nginx -s quit nginx -s reload nginx -s reopen
|
安装Nginx之后需要做的事情
把Nginx设置开机自启
1 2 3 4 5 6 7
| sudo systemctl enable nginx.service
sudo systemctl disable nginx.service sudo systemctl status nginx.service sudo systemctl start nginx.service sudo systemctl stop nginx.service sudo systemctl restart nginx.service
|
根据需求开启防火墙端口
1 2 3 4 5 6 7
| sudo firewall-cmd --zone=public --add-port=80/tcp --permanent sudo firewall-cmd --zone=public --add-port=443/tcp --permanent
sudo firewall-cmd --reload
sudo systemctl restart firewalld.service
|
修改配置文件 nginx.conf
有一个在线配置nginx的web神器,分享给大家 https://www.digitalocean.com/community/tools/nginx
1 2
| 默认配置文件路径:/etc/nginx/nginx.conf `/etc/nginx/conf.d` 这个路径下的conf文件也是nginx默认的配置文件
|