Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
nginx apache wordpress:在子目录下和nginx后面安装apache/wordpress_Wordpress_Apache_Nginx_Rewrite_Subdirectory - Fatal编程技术网

nginx apache wordpress:在子目录下和nginx后面安装apache/wordpress

nginx apache wordpress:在子目录下和nginx后面安装apache/wordpress,wordpress,apache,nginx,rewrite,subdirectory,Wordpress,Apache,Nginx,Rewrite,Subdirectory,我开发了一个Rails应用程序,并对此感到满意,但我被要求在子目录/wp下设置Wordpress。在尝试让nginx到apache代理工作了几个小时之后,我放弃了从蹩脚的指南中复制代码,并编写了一些非常简短和清晰的配置: location @wp { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_redirect off; proxy_pass http://127.0.0.1:8080; }

我开发了一个Rails应用程序,并对此感到满意,但我被要求在子目录
/wp
下设置Wordpress。在尝试让nginx到apache代理工作了几个小时之后,我放弃了从蹩脚的指南中复制代码,并编写了一些非常简短和清晰的配置:

location @wp {
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_redirect off;
  proxy_pass http://127.0.0.1:8080;
}

location ~ ^/wp(/|$) {
  root /home/apache/www;
  rewrite ^/wp/?$ / break;
  rewrite ^/wp/(.*) /$1 break;
  try_files $uri @wp;
}
它解决了我遇到的大多数问题,但由于一个明显的原因,它不起作用: Wordpress会生成
:8080/
链接,这不仅难看(我可以接受),而且链接不起作用,因为Apache只在本地主机上侦听。
我如何告诉Apache或Wordpress(或者我应该用Nginx代理哪个标题)使链接看起来像
/wp/
?还是我的设置设计有问题?我将感谢任何解决方案或提示,谢谢

下面是我对nginx的配置,它在主根目录下运行Rails应用程序,在子目录下运行WordPress博客。也许试试这个

server {
  listen <ip-address>:80;
  server_name domain.com;
  rewrite ^(.*)$ $scheme://www.domain.com$request_uri? permanent;
  break;
}

server {
  listen <ip-address>:80;
  server_name www.domain.com;
  root   /www/domain.com/public_html/current/public;

  access_log /www/domain.com/logs/access.log;
  error_log /www/domain.com/logs/error.log;

  location ^~ /blog {
    root /www/domain.com/blog/public_html;
    index index.php index.html index.htm;
    try_files $uri $uri/ /blog/index.php?$args;

    location ~ \.php$ {
        include /etc/nginx/fastcgi_params;
        if ($uri !~ "^/images/") {
                fastcgi_pass unix:/var/run/php-fastcgi/php-fastcgi.socket;
        }
        fastcgi_index index.php;
        fastcgi_param  SCRIPT_FILENAME  /www/domain.com/blog/public_html$fastcgi_script_name;
   }
}
服务器{
听:80;
server_name domain.com;
重写^(.*)$$scheme://www.domain.com$request_uri?永久性;
打破
}
服务器{
听:80;
服务器名称www.domain.com;
root/www/domain.com/public_html/current/public;
access_log/www/domain.com/logs/access.log;
error_log/www/domain.com/logs/error.log;
地点^~/博客{
root/www/domain.com/blog/public_html;
index.php index.html index.htm;
try_files$uri$uri//blog/index.php?$args;
位置~\.php${
包括/etc/nginx/fastcgi_参数;
如果($uri!~“^/images/”){
fastcgi_pass unix:/var/run/php fastcgi/php-fastcgi.socket;
}
fastcgi_index.php;
fastcgi_param SCRIPT_FILENAME/www/domain.com/blog/public_html$fastcgi_SCRIPT_name;
}
}

您能提供包含的
/etc/nginx/fascgi_params
文件的内容吗?我真的无法让它与此一起工作。