>  기사  >  백엔드 개발  >  Nginx + php 配置 用IP的方式能访问 域名的方式却不可以

Nginx + php 配置 用IP的方式能访问 域名的方式却不可以

WBOY
WBOY원래의
2016-06-23 13:34:02800검색

这是我的nginx.conf文件

#user  nobody;worker_processes  1;#error_log  logs/error.log;#error_log  logs/error.log  notice;#error_log  logs/error.log  info;#pid        logs/nginx.pid;events {    worker_connections  1024;}http {    include       mime.types;    default_type  application/octet-stream;    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '    #                  '$status $body_bytes_sent "$http_referer" '    #                  '"$http_user_agent" "$http_x_forwarded_for"';    #access_log  logs/access.log  main;    sendfile        on;    #tcp_nopush     on;    #keepalive_timeout  0;    keepalive_timeout  65;    #gzip  on;    server {        listen       81;        server_name www.test.com;        root D:/src/web/runroot;        error_page 404  /404.html;        error_page   500 502 503 504  /50x.html; if ($remote_addr !~ "123.125.169.174") {        #       rewrite ^ http://lavaradio.wix.com/lavaradio redirect;        }        rewrite ^/api/(.*?)\.json$    /index.php?route=api/$1&_of=json break;        if (!-f $request_filename) {            rewrite ^/(.*?)$    /index.php?route=$1 last;        }               location /index.php {            fastcgi_pass   127.0.0.1:9000;            fastcgi_index  index.php;            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;            include        fastcgi_params;        }    }    }

我已经在C:\Windows\System32\drivers\etc\hosts加了
127.0.0.1 www.test.com

用127.0.0.1:81 可以访问  用 www.test.com 直接 是“无法显示此网页”


回复讨论(解决方案)

大哥,你得加个端口号好不!
www.test.com:81
如果不要端口号,把81改成80

默认是 80 端口,你改成81就要加端口哦
还有 www.test.com 不是你的真是域名,你就得在本地hosts文件里加上
192.168.1.100 www.test.com
192.168.1.100就是你的nginx所在服务器的ip

直接用 phpfind 的吧,没必要在配置上浪费时间

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.