Home > Backend Development > PHP Tutorial > Nginx + php 配置 用IP的模式能访问 域名的方式却不可以

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

WBOY
Release: 2016-06-13 12:20:31
Original
1367 people have browsed it

Nginx + php 配置 用IP的方式能访问 域名的方式却不可以
这是我的nginx.conf文件

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

我已经在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 的吧,没必要在配置上浪费时间

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template