修改 nginx.conf 文件實現。在 Linux 上該文件的路徑為 /usr/local/nginx/conf/nginx.conf,Windows 下 安裝目錄\conf\nginx.conf。
server {
listen 80;
server_name localhost;
……
}
server {
listen 81;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
……
}
當然改成 8080,8081 什么的都可以,不一定要 81,但是確保 iptable 要放開對該端口的訪問。
注意到 location 的配置:
root html; #根目錄,相對於安裝目錄
index index.html index.htm; #默認主頁
默認,你把文件放在安裝目錄下的 html 文件夾,即可通過 Nginx 訪問