nginx 虛擬主機 修改 hosts 解析域名指向本地ip
阿新 • • 發佈:2019-02-10
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頁面了