简体   繁体   English

在子目录nginx中的Wordpress

[英]Wordpress in subdirectory nginx

Hi I have an Nginx Server with running wp's with no problem. 嗨,我有一个运行wp的Nginx服务器没有问题。 I just created a site in blank html5 and added some functions with php. 我刚刚用空白的html5创建了一个网站,并用php添加了一些功能。 Then my client decided to have a blog too. 然后我的客户决定也有一个博客。 So i installed Wordpress into a subdirectory. 所以我将Wordpress安装到子目录中。 My only problem is the Nginx config which I cant figure it out. 我唯一的问题是Nginx配置,我无法弄明白。 I have the site on example.com/ the wp is on example.com/wp/site/ But even when i have configured everything correctly My Admin panel does not works. 我在example.com/上有网站,wp在example.com/wp/site/上,但即使我已经正确配置了一切我的管理面板也不起作用。 So i share my code, and I would highly appreciate some help. 所以我分享我的代码,我非常感谢一些帮助。 I have found similar articles online, but they does not help at all. 我在网上发现了类似的文章,但它们根本没有帮助。 So please take a look at my Nginx cfg for this site, and tell me whats wrong. 所以,请看看我的Nginx cfg这个网站,并告诉我什么是错的。 Thank you! 谢谢!

    server {
  server_name domain.com;
  listen 80;
  root /var/www/domain;
  include wordpress.conf;

 location / {
 index index.php index.html index.htm;
}

  # Block PHP files in uploads directory.
  location ~* /wp/acc/wp-content/uploads/.*\.php$ {
    deny all;
  }
  location ~ ^/\.user\.ini {
    deny all;
  }
  location /wp/acc {
    limit_except GET POST OPTIONS HEAD { deny all; }
    try_files $uri $uri/ /wp/acc/index.php?$args;
  }
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
server {
  server_name domain.com;
  listen 81;
  root /var/www/domain;
 index index.php index.html index.htm;
  include wordpress7080.conf;

 location / {
index index.php index.html index.htm;
}

  # Block PHP files in uploads directory.
  location ~* /wp/acc/wp-content/uploads/.*\.php$ {
    deny all;
  }
  location ~ ^/\.user\.ini {
    deny all;
  }
  location / {
    limit_except GET POST OPTIONS HEAD { deny all; }
    try_files $uri $uri/ /wp/acc/index.php?$args;
  }
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}

Additional Info: 附加信息:

Wp-config.php has not been modified. Wp-config.php尚未修改。 Url's in database are correct. 数据库中的Url是正确的。 Wordpress.conf only includes basic wordpress setup for nginx. Wordpress.conf只包含nginx的基本wordpress设置。

you have to change the root statement to the directory of each wordpress in the server { } code block 您必须将root语句更改为server {}代码块中每个wordpress的目录

root /var/www/wp1;
root /var/www/wp2;

Also, you can check in your 此外,您可以登记入住

/var/log/nginx/error* 
/var/log/nginx/access*

to get more information on how things are working. 获得有关事情如何运作的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM