为什么我不能使用这个Nginx + Ruby On Rails + WordPress设置访问wp-admin?

这是我的单个Linux VPS设置:

  • 一个由Nginx背后的瘦应用程序服务器运行的Rails应用程序。
  • 由同一个Nginx服务器的lighttpd的spawn-fcgi运行的一个WordPress博客。

这是我想要的:

这两个应用程序在同一个域下运行。 所有以/ blog或/ wp-开头,或以.php结尾的URI都应该到达fastcgi服务器。 其他一切都应该去瘦服务器。

这是我的问题:

我的Rails应用程序工作正常。 我的WordPress博客的正面工作正常。 但是,我不能访问WordPresspipe理面板(/ wp-admin或/wp-login.php)。 这个问题必须与我的Nginx的conf。

这是我的Nginx conf:

upstream myserver { server unix:/tmp/myserver.0.sock; server unix:/tmp/myserver.1.sock; } server { server_name myserver; root /path/to/rails/app/public; index index.html; access_log /path/to/rails/app/log/access.log; error_log /path/to/rails/app/log/error.log; <snip> location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect false; if (-f $document_root/cache$request_uri/index.html) { rewrite (.*) /cache$1/index.html break; } if (-f $document_root/cache$request_uri.html) { rewrite (.*) /cache$1.html break; } if (!-f $request_filename) { proxy_pass http://myserver; break; } } location ~ /(blog|wp-).* { root /path/to/wordpress; index index.php; access_log /path/to/wordpress/log/access.log; error_log /path/to/wordpress/log/error.log; if (!-e $request_filename) { rewrite ^ /index.php last; } } # # pass the PHP scripts to FastCGI server location ~ \.php$ { root /path/to/wordpress; index index.php; access_log /path/to/wordpress/log/access.log; error_log /path/to/wordpress/log/error.log; fastcgi_pass unix:/tmp/fcgi.sock; fastcgi_index index.php; include /etc/nginx/fastcgi_params; fastcgi_param SCRIPT_FILENAME /path/to/wordpress/$fastcgi_script_name; } } 

当我打开debugging日志到WordPress错误日志。 当我请求时,我从来没有看到/ wp-admin的匹配。 这使我相信这个请求正在被location /于Rails应用程序的location /规则所处理。 当我要求/ wp-admin时,浏览器会提示我“另存为”一些名为“下载”的文件。

请注意,wp-content目录下的资源在达到location ~ /(blog|wp-).* /( location ~ /(blog|wp-).* wp-). location ~ /(blog|wp-).*规则时(为什么不/ wp-admin在那里?

我的问题:

我需要什么规则才能拥有我想要的设置并能够访问WPpipe理面板?

提前致谢。

我发现了一个解决方法。 我更改了location ~ /(blog|wp-).*location ~ /blog.*并在我的请求中使用了/wp-admin/index.php 。 然后,我得到了我想要的。 我仍然没有想/wp-admin/index.php /wp-admin/wp-admin/index.php产生相同结果的/wp-admin/index.php ,但是我可以没有它。 其他一切都按预期工作。

关于Wordpress的Nginx wiki文章应该帮助: http : //wiki.nginx.org/Wordpress

你有正确的根和索引,所以我猜这只是如果检查是奇怪的,try_files将帮助你。