Nginx的端口修改问题

2016-05-18 11:47:51 7532

修改 nginx.conf 文件实现。在 Linux 上该文件的路径为 /usr/local/nginx/conf/nginx.conf,Windows 下 安装目录conf ginx.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 访问。


提交成功!非常感谢您的反馈,我们会继续努力做到更好!

这条文档是否有帮助解决问题?

非常抱歉未能帮助到您。为了给您提供更好的服务,我们很需要您进一步的反馈信息:

在文档使用中是否遇到以下问题: