Php Nginx:分别为wordpress核心和wp内容文件夹提供服务
我在Wordpress安装外部的Php Nginx:分别为wordpress核心和wp内容文件夹提供服务,php,wordpress,nginx,Php,Wordpress,Nginx,我在Wordpress安装外部的wp content文件夹中为我的Wordpress站点提供服务时遇到问题 --- /var/www | | -- /var/www/wordpress | | -- /var/www/wp-content 这是我的Nginx配置: user nginx; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.p
wp content
文件夹中为我的Wordpress站点提供服务时遇到问题
--- /var/www
|
|
-- /var/www/wordpress
|
|
-- /var/www/wp-content
这是我的Nginx配置:
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
proxy_headers_hash_max_size 1024;
# buffering
client_body_buffer_size 10K;
client_header_buffer_size 1k;
client_max_body_size 8m;
large_client_header_buffers 2 1k;
keepalive_timeout 15;
# Gzip compression
gzip on;
gzip_comp_level 6;
gzip_vary on;
gzip_min_length 1000;
gzip_proxied any;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_buffers 16 8k;
# logging
rewrite_log on;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log notice;
# mime types
include /etc/nginx/mime.types;
index index.php;
# server
server {
listen 80 default_server;
root /var/www;
index index.php index.html index.htm;
large_client_header_buffers 4 32k;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location / {
try_files /wordpress/$uri /wordpress/$uri/ /wordpress/index.php?q=$uri&$args;
}
location /wp-content {
try_files /wp-content/$uri /wp-content/$uri/ /wp-content/index.php?q=$uri&$args;
}
location ~ \.php$ {
client_max_body_size 50M;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_set_header Connection "";
fastcgi_keep_conn on;
fastcgi_pass unix:/var/run/php7-fpm.sock;
fastcgi_index index.php;
fastcgi_read_timeout 300s;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}
}
虽然字体和css之类的东西没有加载,但这“有点”起作用。我建议运行debug()日志,看看完成了什么文件请求,假设是这样的
/wp content//wp content/…css
。尝试只使用Try_文件$uri/wordpress/index.php?q=$uri&$args
。我建议阅读优秀的文档nginx如何处理请求。另一方面,您可以创建一个名为wp content的符号链接到../wp content。并将根目录设置为/var/www/wordpress/。又快又脏。我建议运行debug()日志,看看完成了什么文件请求,假设是/wp content//wp content/…css
。尝试只使用Try_文件$uri/wordpress/index.php?q=$uri&$args
。我建议阅读优秀的文档nginx如何处理请求。另一方面,您可以创建一个名为wp content的符号链接到../wp content。并将根目录设置为/var/www/wordpress/。又快又脏。