HTTP 反向代理。
另请参阅: netstat ufw Nginx 1.15.6 Documentation
基本语法 Basic Usage Detailed Usage 配置 Nginx 测试 Nginx 重启 Nginx
nginx [-?hvVtTq] [-s signal] [-c filename] [-p prefix] [-g directives]
选项参数
| 参数 | EN 解释 | 中文翻译 | Remark |
|---|---|---|---|
| -?,-h | this help | 此帮助 | |
| -v | show version and exit | 展示版本并退出 | |
| -V | show version and configure options then exit | 展示版本和配置选项,然后退出 | |
| -t | test configuration and exit | 测试配置并退出 | |
| -T | test configuration, dump it and exit | 测试配置,转储它并退出 | |
| -q | suppress non-error messages during configuration testing | 在配置测试期间,抑制非错误消息 | |
| -s signal | send signal to a master process: stop, quit, reopen, reload | 把信号发送给主进程:停止 离开 重新打开 重装 | |
| -p prefix | set prefix path (default: /usr/share/nginx/) | 设置前缀路径 (默认:/usr/share/nginx/) | |
| -c filename | set configuration file (default: /etc/nginx/nginx.conf) | 设置配置文件 (默认:/etc/nginx/nginx.conf) | |
| -g directives | set global directives out of configuration file | 设置配置文件外的全局指令 |
| Function | 命令 | 文字解释 | 示例 | 示例解释 |
|---|---|---|---|---|
| 帮助 | nginx -? | 展示帮助信息 | ||
| nginx -h | ||||
| Version | nginx -v | 展示版本信息 | ||
| nginx -V | 展示版本信息 配置选项 |
apt-get update --> apt-get dist-upgrade --> apt-get install nginx --> dpkg -l nginx (查看 nginx 版本) --> shutdown -r +1 查看 http://localhost/ 或 http://127.0.0.1/ 或 http://47.244.22.120/ --> 若出现 Welcome to nginx! 信息,说明安装成功
移除 Nginx
apt-get purge nginx* --> apt-get autoremove find / -name nginx | xargs rm -rf
目录结构
虚拟主机 vi /etc/nginx/sites-available/default 配置文件 vi /etc/nginx/nginx.conf 启动程序 vi /usr/sbin/nginx 日志文件 sudo vi /var/log/nginx/access.log sudo vi /var/log/nginx/error.log 默认根 /var/www/html /usr/share/nginx/html
ps -ef --> ps aux|grep nginx --> killall nginx --> service nginx start apt-get purge nginx* --> apt-get autoremove netstat -ntpl
防火墙
ufw status (查看防火墙) --> 若为 Status: inactive (ufw disable),则 ufw enable (启用防火墙) --> ufw allow 20/tcp --> ufw allow 21/tcp --> ufw allow 22/tcp (SSH 专用端口) sudo ufw app list --> ufw allow "Nginx Full"
cd /etc/nginx/sites-available vi /etc/nginx/sites-available/default --> :set nu --> :set tabstop=4 chmod -R 777 /etc/nginx/sites-available
重载配置
/usr/sbin/nginx -s reload service nginx reload (systemctl reload nginx.service)
/usr/sbin/nginx -t --> ps -aux | grep nginx nginx -c /etc/nginx/nginx.conf --> service nginx status
/etc/init.d/nginx stop 或 service nginx stop (systemctl stop nginx.service) /etc/init.d/nginx start 或 service nginx start (systemctl start nginx.service) /etc/init.d/nginx restart 或 service nginx restart (systemctl restart nginx.service)
Copyright Notice: This article is an exclusive original manuscript, copyright belongs to Happy Digits Software , shall not be reproduced without permission.