Nginx 是一个高性能的 HTTP 和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器。 Nginx 是由 Igor Sysoev 为俄罗斯访问量第二的 Rambler.ru 站点开发的,第一个公开版本 0.1.0 发布于 2004 年 10 月 4 日。其将源代码以类 BSD 许可证的形式发布,因它的稳定性、丰富的功能集、示例配置文件和低系统资源的消耗而闻名。
这篇文章主要为大家详细介绍了 windows 下 Nginx 多域名简单配置教程,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
1. windows 下安装 nginx 的目录结构如下:
2. 在 nginx-1.12.1 目录下 conf/nginx.conf 内容
- #user nobody;
- worker_processes 1;
- events {
- worker_connections 1024;
- }
- http {
- include mime.types;
- default_type application / octet - stream;
- sendfile on;
- keepalive_timeout 65;
- server {
- listen 80 default_server;
- server_name localhost default_server;
- root html;
- location / {
- index index.html index.htm;
- }
- }
- include.. / vhost
- /*.conf;
- }*/
3. vhost 目录下 a_com.conf 内容:
- server {
- listen 80;
- server_name www.a.com;
- root D: /test/;
- location / {
- index index.html index.htm;
- }
- }
4. vhost 目录下 b_com.conf 内容:
- server {
- listen 80;
- server_name www.b.com;
- root D: /test2/;
- location / {
- index index.html index.htm;
- }
- }
5. 在本地磁盘 D 盘下 新建 test 和 test2 目录,并新建 index.html 文件
6. 在本地磁盘 C 盘中 C:\Windows\System32\drivers\etc 下修改 hosts 如下
- 127.0.0.1 www.a.com
- 127.0.0.1 www.b.com
7. 用 cmd 进入 nginx 安装目录下执行
nginx.exe 开始
nginx -t // 检测语法
nginx -s reload // 重新启动
nginx -s stop // 停止
8. 打开浏览器输入网址
github 仓库:https://github.com/chengzao
来源: http://www.phperz.com/article/17/0825/344281.html