您的位置:首页 > 运维架构 > Nginx

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

2015-06-29 17:16 519 查看
一台机子部署多个网站,我们直接访问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;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: