1. 首先下载 nginx
下载地址:http://nginx.org/en/download.html
2. 将下载后的压缩包解压
3. 进入命令行启动 nginx
进入 cmd 命令行,进入到 nginx 的目录
启动 nginx.exe
打开任务管理发发现有 nginx.exe(32位)的进程
4. 配置 nginx.conf 文件
用 notepad++ 打开 nginx-1.10.2/conf/nginx.conf 文件
在 95 行处机上 include vhost/*.host;
5. 创建一个域名配置文件
在 nginx-1.10.2/conf 中创建一个 txt 文件
扫描二维码关注公众号,回复:
3666155 查看本文章
改名为 img.yuu.com.conf 后缀是.conf
用 notepad++ 打开配置如下
server {
listen 80;
autoindex off;
server_name img.yyh.com;
access_log c:/access.log combined;
index index.html index.htm index.jsp index.php;
#error_page 404 /404.html;
if ( $query_string ~* ".*[\;'\<\>].*" ){
return 404;
}
location ~ /(mmall_fe|mmall_admin_fe)/dist/view/* {
deny all;
}
location / {
root E:\ftpfile\img;
add_header Access-Control-Allow-Origin *;
}
}
6. 配置 host 文件
打开 windos -> System32 -> dirvers -> hosts
在后面加上一句
127.0.0.1 img.yyh.com
7. 重启 nginx
8. 浏览器访问
浏览器访问 img.yuu.com/test.jpg