小知识:windows下Nginx多域名简单配置教程

本文实例为大家分享了Nginx多域名的简单配置教程,供大家参考,具体内容如下

1. windows下安装nginx的目录结构如下:

%小知识:windows下Nginx多域名简单配置教程-猿站网-插图

2. 在nginx-1.12.1目录下conf/nginx.conf 内容

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#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 内容:

?
1
2
3
4
5
6
7
8
server {
listen    80;
server_name www.a.com;
root  D:/test/;
location / {
index index.html index.htm;
}
}

4. vhost 目录下 b_com.conf 内容:

?
1
2
3
4
5
6
7
8
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 如下

?
1
2
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

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。

声明: 猿站网有关资源均来自网络搜集与网友提供,任何涉及商业盈利目的的均不得使用,否则产生的一切后果将由您自己承担! 本平台资源仅供个人学习交流、测试使用 所有内容请在下载后24小时内删除,制止非法恶意传播,不对任何下载或转载者造成的危害负任何法律责任!也请大家支持、购置正版! 。本站一律禁止以任何方式发布或转载任何违法的相关信息访客发现请向站长举报,会员发帖仅代表会员个人观点,并不代表本站赞同其观点和对其真实性负责。本网站的资源部分来源于网络,如有侵权烦请发送邮件至:2697268773@qq.com进行处理。
建站知识

小知识:linux下安装php扩展memcache的方法

2023-4-23 1:55:03

建站知识

小知识:Linux下用SSH退出符切换SSH会话的实现方法

2023-4-23 2:03:25

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索