【发布时间】:2017-03-11 13:44:32
【问题描述】:
我想用一个简单的 php 应用程序配置一个 Wordpress 应用程序。 应用程序的目录结构如下:
根目录:/var/www/demoApp/
Wordpress 目录:/var/www/demoApp/wordpress/
在这里,我想使用路由 http://BASE_URL/wordpress 访问 wordpress 应用程序。但我无法配置 Web 服务器。 /var/www/demoApp/ 目录下的所有 php 页面都可以使用 url http://BASE_URL/ 正常工作。虽然没有正确加载 wordpress 文件。
这是我的 Nginx 配置块:
server
{
listen 80;
root /var/www/demoApp;
index index.php index.html index.htm;
server_name localhost;
error_page 500 404 /404.php;
location /
{
try_files $uri $uri/ /index.php?$query_string;
}
location /wordpress
{
try_files $uri $uri/ /index.php?$query_string;
rewrite ^(.*)$ /wordpress/index.php?$1 last;
location ~ \.php
{
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
location ~ \.php$
{
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
配置有什么问题?
【问题讨论】: