在nginx中配置ip直接访问的默认站点


 

 

 

 

一台机子部署多个网站,我们直接访问ip (外网内网都一样)提示无法访问或404.

因为有多个网站,我们想指定某个网站为IP访问默认的网站,如何操作呢?

 

解:在Listen ip:port; 这个指令行中,加参数default

这个server段就会是这个ip的默认站点

server {
        listen       80 default;
        server_name  web.com ;
        location / {
            root   F:/project/web;
            index  index.html index.htm index.php;
            autoindex  on;
        }
        location ~ \.php$ {
            root          F:/project/web;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM