Nginx:修订间差异
来自康健生活
无编辑摘要 |
|||
| 第3行: | 第3行: | ||
* [[Linux:Nginx/配置|配置]] | * [[Linux:Nginx/配置|配置]] | ||
== | == 安装 == | ||
=== windows === | |||
==== WAMP ==== | |||
==== source ==== | |||
在 [http://nginx.org/en/download.html nginx] 下载 windows 版本的 nginx,将其解压到 windows 系统的 c 目录下。 | |||
命令的操作方式。 | |||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
| | | start || {{shc|<syntaxhighlight lang="bash"> | ||
cd c:\nginx-1.18.0 | |||
start nginx</syntaxhighlight>|PS C:\nginx-1.18.0>}} | |||
|- | |||
| stop || <code>nginx -s stop</code> 即停止nginx,不保存相关信息 | |||
|- | |||
| quit || <code>nginx -s quit</code> 正常退出nginx,并保存相关信息 | |||
|- | |- | ||
| | | reload || {{shc|<syntaxhighlight lang="bash"> | ||
./nginx -s reload</syntaxhighlight>|PS C:\nginx-1.18.0>}} | |||
|- | |- | ||
| | | t || {{shc|<syntaxhighlight lang="bash"> | ||
./nginx -t -c '.\conf\nginx.conf'</syntaxhighlight>|PS C:\nginx-1.18.0>}} | |||
|} | |} | ||
== | |||
可以使用 tasklist 命令查看任务进程是否存在。 | |||
{{shc|<syntaxhighlight lang="bash"> | |||
tasklist /fi "imagename eq nginx.exe"</syntaxhighlight>|PS C:\nginx-1.18.0>}} | |||
=== mac === | |||
==== MAMP === | |||
==== brew ==== | |||
通过 brew 命令搜索 nginx 应用。 | |||
{{Shc_out|<syntaxhighlight lang="bash"> | |||
brew search nginx</syntaxhighlight>|<syntaxhighlight lang="bash"> | |||
==> Formulae | |||
nginx | |||
</syntaxhighlight>|$|/home/kangkk}} | |||
找到应用后进行安装 nginx。 | |||
{{shc|<syntaxhighlight lang="bash"> | |||
brew install nginx</syntaxhighlight>|$|/home/kangkk}} | |||
验证 nginx 安装是否成功。 | |||
{{Shc_out|<syntaxhighlight lang="bash"> | |||
nginx -v</syntaxhighlight>|<syntaxhighlight lang="bash">nginx version: nginx/1.21.5 | |||
</syntaxhighlight>|$|/home/kangkk}} | |||
命令的操作方式。 | |||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
| | | start || {{shc|<syntaxhighlight lang="bash"> | ||
# 方式一 | |||
nginx | |||
# 方式二 | |||
sudo /usr/local/Cellar/nginx/1.21.5/bin/nginx | |||
# 方式三 | |||
brew services start nginx | |||
</syntaxhighlight>|$|/home/kangkk}} | |||
|- | |||
| reload || {{shc|<syntaxhighlight lang="bash"> | |||
sudo /usr/local/Cellar/nginx/1.21.5/bin/nginx -s reload | |||
</syntaxhighlight>|$|/home/kangkk}} | |||
|- | |- | ||
| | | stop || {{shc|<syntaxhighlight lang="bash"> | ||
# 关闭 | |||
sudo /usr/local/Cellar/nginx/1.21.5/bin/nginx -s stop | |||
# down 掉进程 | |||
ps -ef|grep nginx | |||
# 正常杀死进程 | |||
sudo kill -QUIT 主进程号 | |||
# 快死杀死进程 | |||
sudo kill -TERM 主进程号 | |||
</syntaxhighlight>|$|/home/kangkk}} | |||
|- | |- | ||
| | | info || {{Shc_out|<syntaxhighlight lang="bash"> | ||
brew services info nginx</syntaxhighlight>|<syntaxhighlight lang="bash"> | |||
nginx (homebrew.mxcl.nginx) | |||
Running: ✘ | |||
{{Shc_out|<syntaxhighlight lang="bash"> | Loaded: ✘ | ||
Schedulable: ✘ | |||
</syntaxhighlight>|$|/home/kangkk}} | </syntaxhighlight>|$|/home/kangkk}} | ||
|- | |||
{{ | | t || {{shc|<syntaxhighlight lang="bash"> | ||
sudo /usr/local/Cellar/nginx/1.21.5/bin/nginx -t | |||
</syntaxhighlight>|$|/home/kangkk}} | </syntaxhighlight>|$|/home/kangkk}} | ||
|} | |||
==== 配置 ==== | |||
相关目录所在。 | |||
{| class="wikitable" | |||
|- | |||
| 配置目录 || <code>/usr/local/etc/nginx/nginx.conf</code> | |||
|- | |||
| 文件目录 || <code>/usr/local/var</code> | |||
|- | |||
| 安装目录 || <code>/usr/local/Cellar/nginx/</code> | |||
|- | |||
| 执行文件 || <code>/usr/local/etc/nginx/servers</code> | |||
|} | |||
=== linux === | |||
命令的操作方式。 | |||
= | {| class="wikitable" | ||
|- | |||
{{Shc_out|<syntaxhighlight lang="bash"> | | t || {{Shc_out|<syntaxhighlight lang="bash"> | ||
nginx -t</syntaxhighlight>|<syntaxhighlight lang="bash"> | nginx -t</syntaxhighlight>|<syntaxhighlight lang="bash"> | ||
</syntaxhighlight>|$|/home/kangkk}} | </syntaxhighlight>|$|/home/kangkk}} | ||
| 第47行: | 第125行: | ||
nginx -t -c /usr/nginx/conf/nginx.conf</syntaxhighlight>|<syntaxhighlight lang="bash"> | nginx -t -c /usr/nginx/conf/nginx.conf</syntaxhighlight>|<syntaxhighlight lang="bash"> | ||
</syntaxhighlight>|$|/home/kangkk}} | </syntaxhighlight>|$|/home/kangkk}} | ||
|} | |||
== 服务 == | |||
=== 进程 === | |||
查看进程。 | |||
{{Shc_out|<syntaxhighlight lang="bash"> | {{Shc_out|<syntaxhighlight lang="bash"> | ||
nginx | ps -ef | grep nginx</syntaxhighlight>|<syntaxhighlight lang="bash"> | ||
</syntaxhighlight>|$|/home/kangkk}} | </syntaxhighlight>|$|/home/kangkk}} | ||
杀死进程。 | |||
{{Shc_out|<syntaxhighlight lang="bash"> | {{Shc_out|<syntaxhighlight lang="bash"> | ||
nginx | kill -TERM 进程号 | ||
# or | |||
kill -INT 进程号 | |||
# or | |||
kill -QUIT 进程号 | |||
# or | |||
pkill -9 nginx</syntaxhighlight>|<syntaxhighlight lang="bash"> | |||
</syntaxhighlight>|$|/home/kangkk}} | </syntaxhighlight>|$|/home/kangkk}} | ||
| 第62行: | 第152行: | ||
kill -HUP 进程号</syntaxhighlight>|<syntaxhighlight lang="bash"> | kill -HUP 进程号</syntaxhighlight>|<syntaxhighlight lang="bash"> | ||
</syntaxhighlight>|$|/home/kangkk}} | </syntaxhighlight>|$|/home/kangkk}} | ||
== 参数 == | |||
{| class="wikitable" | |||
|- | |||
| permanent | |||
|- | |||
| redirect | |||
|} | |||
=== other === | |||
{| class="wikitable" | |||
|- | |||
| [[/favicon.ico|favicon.ico]] || 示例 || 示例 | |||
|} | |||
== 日志 == | == 日志 == | ||
| 第76行: | 第180行: | ||
proxy_pass http://127.0.0.1:8080; | proxy_pass http://127.0.0.1:8080; | ||
}</pre> | }</pre> | ||
== 转发 == | == 转发 == | ||