win下本地架设了nginx服务器,想要设置一个酷一点的本地域名- -
首先找到C:\WINDOWS\System32\drivers\etc\hosts用记事本打开在最后一行加入想要的域名和对应的ip地址
比如 127.98.8.10 www.ulelouch.com
然后打开nginx的配置文件 nginx.conf文件 修改server配置
server {
listen 80;
server_name www.ulelouch.com;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
add_header Access-Control-Allow-Origin *;
root G:/ulelouch/ulelouch;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
add_header Access-Control-Allow-Origin *;
root G:/ulelouch/ulelouch;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
最后重启nginx服务就可以通过自己设置的域名访问本地web页面了