1.在nginx的安装目录下,找到conf文件夹并打开,找到nginx.conf文件并打开
修改配置如下所示(只需要修改server即可):
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
#要修改的配置全部在这,别的地方无需改动,配置域名及默认加载的页面
server{
listen 80;
server_name www.***.com;
ssi on;
ssi_silent_errors on;
location / {
alias G:/hello/world/;
index index.html;
}
}
}
2.打开此文件夹:C:\Windows\System32\drivers\etc,找到hosts文件,添加以下配置 (引号里的内容,域名和nginx配置文件里的域名一致)“127.0.0.1 www.***.com”。
3.在浏览器输入:“http://localhost/”或“http://www.***.com/”便可访问index.html(nginx配置文件里所配置的index.html页面)页面了。