我已经看了好几个小时,但尽管花了很多时间在谷歌上搜索,但仍然无法到达我要去的地方.Nginx抛出了未指定输入文件
Ive looked at this for hours, but am still not getting where I need to get to despite doing a lot of hours googling.Nginx is throwing no input file specified
我的配置如下:
upstream site { #flask app server 127.0.0.1:8001; } upstream siteb-blog { #wordpress php server unix:/var/run/php5-fpm.sock; } server { server_name siteb; listen 80; root /home/www/flask-deploy/siteb; location ~* ^blog/ { try_files $uri $uri/ /blog/index.php?$query_string; root /home/www/flask-deploy/siteb-blog; location ~ \.php$ { fastcgi_pass siteb-blog; fastcgi_param SCRIPT_FILENAME $request_filename; include fastcgi_params; } } location / { try_files @proxy @proxy; } location @proxy { internal; proxy_pass siteb; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location /static { alias /home/www/flask-deploy/siteb/static/; } }但是,当我尝试访问 mysite/blog 或 mysite/blog/info.php 时,出现404错误.
However, when i try to access mysite/blog or mysite/blog/info.php i get a 404 error.
ive检查了 error.log ,它没有显示任何错误. access.log ,仅显示:
ive checked error.log and it doesnt show any errors. access.log, just shows:
[16/Dec/2016:16:11:56 -0500] "GET /blog/index.php HTTP/1.1" 404 209 "-" "Mozilla/5.0 (X11; Ubuntu; Linux armv7l; rv:50.0) Gecko/20100101 Firefox/50.0"我的 siteb 正常工作. siteb/blog 不会.
im专门尝试在 siteb/blog 上使 siteb-blog 工作.
im specifically trying to get siteb-blog working at siteb/blog.
提前谢谢!
推荐答案您已将WordPress安装在名为 siteb-blog 的目录下,并希望使用/博客/.您的问题之一是 $ request_filename 是由 root 和URI构造的,因此/blog 段成为路径名的一部分.有关详细信息,请参见本文档.
You have WordPress installed under a directory called siteb-blog and would like to access it with a URI prefix of /blog/. One of your problems is that the $request_filename is constructed from the root and URI, so that the /blog segment becomes part of the pathname. See this document for details.
使用静态文件的简单解决方案是使用 alias 指令,但是由于一个长期存在的错误.
The simple solution with static files is to use the alias directive, but I try to avoid using it with try_files because of a long standing bug.
我的首选解决方案是静默地(使用内部重写)将/blog URI映射到/siteb-blog ,然后继续使用 root 正常.
My preferred solution is to silently (using internal rewrite) map the /blog URI to /siteb-blog, then continue to use root as normal.
例如:
server { server_name siteb; listen 80; location /blog { rewrite ^/blog(.*)$ /siteb-blog$1 last; } location /siteb-blog { root /home/www/flask-deploy; try_files $uri $uri/ /blog/index.php?$query_string; location ~ \.php$ { try_files $uri /blog/index.php; fastcgi_pass siteb-blog; fastcgi_param SCRIPT_FILENAME $request_filename; include fastcgi_params; } } location / { proxy_pass siteb; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location /static { root /home/www/flask-deploy/siteb; } }- 您可以通过添加 internal 指令使 location/siteb-blog 内部.这将使其直接不可访问.
- server 块和 location/static 块中的 root 语句都是不必要的-它只需出现一次.
- 不需要 alias -首选 root .有关详细信息,请参见本文档.
- 命名的位置是不必要的-与 location/ 合并
- You can make the location /siteb-blog internal, by adding the internal directive. This will make it inaccessible directly.
- A root statement in both the server block and the location /static block is unnecessary - it only needs to appear once.
- The alias was unnecessary - root is preferred. See this document for details.
- The named location was unnecessary - merged with location /
最后,WordPress 需要知道它托管在/blog 下,否则它无法找到其资源文件(css和js).您将需要使用 wp-config.php 或使用WordPress⇒设置 WP_SITEURL 和 WP_HOME 的值.仪表板⇒设置⇒常规页面.
Finally, WordPress needs to know that it is hosted under /blog, otherwise it cannot find its resource files (css & js). You will need to set the values for WP_SITEURL and WP_HOME either using wp-config.php or using the WordPress ⇒ DashBoard ⇒ Settings ⇒ General page.
更多推荐
Nginx在访问siteb.com/blog时抛出“未指定输入文件"
发布评论