Nginx 实战-01-nginx windows 安装笔记
2018年11月22日大约 3 分钟
前言
大家好,我是老马。很高兴遇到你。
我们为 java 开发者实现了 java 版本的 nginx
如果你想知道 servlet 如何处理的,可以参考我的另一个项目:
手写从零实现简易版 tomcat minicat
手写 nginx 系列
如果你对 nginx 原理感兴趣,可以阅读:
从零手写实现 nginx-01-为什么不能有 java 版本的 nginx?
从零手写实现 nginx-03-nginx 基于 Netty 实现
从零手写实现 nginx-04-基于 netty http 出入参优化处理
从零手写实现 nginx-05-MIME类型(Multipurpose Internet Mail Extensions,多用途互联网邮件扩展类型)
从零手写实现 nginx-12-keep-alive 连接复用
环境说明
本地 windows 安装 nginx
安装笔记
下载
访问 Nginx 官方网站的 Windows 版本页面:https://nginx.org/en/docs/windows.html
此处选择:https://nginx.org/download/nginx-1.26.0.zip
解压
下载后解压,如下:
cd D:\tool\nginx\nginx-1.26.0\nginx-1.26.0
λ ls
conf/ contrib/ docs/ html/ logs/ nginx.exe* temp/
启动
start nginx # 启动服务
验证
>curl http://localhost/
Welcome to nginx!
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
Welcome to nginx!
If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.
For online documentation and support please refer to
nginx.org.
Commercial support is available at
nginx.com.
Thank you for using nginx.
chat
windows 如何实现 nginx 安装
在 Windows 上安装 Nginx 相对简单,以下是基本步骤:
下载 Nginx:
- 访问 Nginx 官方网站的 Windows 版本页面:https://nginx.org/en/docs/windows.html
- 下载 Windows 版本的 Nginx。
解压下载的文件:
- 将下载的 Nginx 压缩包解压到一个你希望安装 Nginx 的目录中,比如
C:\nginx
。
- 将下载的 Nginx 压缩包解压到一个你希望安装 Nginx 的目录中,比如
运行 Nginx:
- 打开命令提示符或 PowerShell。
- 切换到 Nginx 的解压目录,例如,如果解压到了
C:\nginx
,则输入cd C:\nginx
。 - 启动 Nginx,运行以下命令:
start nginx
- 你可以通过浏览器访问
http://localhost
来检查 Nginx 是否正在运行。
配置 Nginx:
- Nginx 的配置文件通常位于解压目录中的
conf
文件夹内,名为nginx.conf
。 - 你可以编辑这个文件来设置服务器块、配置代理、添加 SSL 证书等。
- Nginx 的配置文件通常位于解压目录中的
设置服务(可选):
- 如果你希望 Nginx 作为 Windows 服务运行,可以使用以下命令来安装和启动服务:
nginx -s stop # 停止当前运行的 Nginx nginx -s install # 安装为 Windows 服务 start nginx # 启动服务
- 如果你希望 Nginx 作为 Windows 服务运行,可以使用以下命令来安装和启动服务:
参考资料
贡献者
binbin.hou