[英]nginx and wordpress in subdirectory results in access denied
我有兩個Rails應用程序和一個wordpress在同一域上運行。 Rails應用程序運行正常,但是我無法使wordpress在子目錄下工作。 它從根服務。
我在nginx error.log中收到以下錯誤。 請注意路徑中的雙wordpress,這就是問題所在,但我不知道如何解決! 真正的路徑是/ var / www / wordpress,而不是/ var / www / wordpress / wordpress!
2017/12/16 21:15:18 [error] 17341#17341: *7 FastCGI sent in stderr: "Access
to the script '/var/www/wordpress/wordpress' has been denied (see
security.limit_extensions)" while reading response header from upstream,
client: ...
這是我的Nginx配置:
server {
server_name www.example.com;
listen 443 ssl;
root /var/www/first_rails_app/public;
passenger_enabled on;
passenger_app_root /var/www/first_rails_app/;
passenger_document_root /var/www/first_rails_app/public;
rails_env production;
index index.htm index.html;
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location /wordpress {
try_files $uri $uri/ /wordpress/index.php?$args;
root /var/www/wordpress;
index index.php;
passenger_enabled off;
location ~ .php(?|$) {
try_files $uri =404;
fastcgi_split_path_info ^(/wordpress)(/.*)$;
fastcgi_pass unix:/run/php/php5.6-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
#passenger_enabled off;
}
}
location ~ ^/second_rails_app(/.*|$) {
alias /var/www/second_rails_app/public$1; # <-- be sure to point to 'public'!
passenger_base_uri /second_rails_app;
passenger_app_root /var/www/second_rails_app/;
passenger_document_root /var/www/second_rails_app/public;
passenger_enabled on;
}
ssl_session_timeout 5m;
ssl_protocols TLSv1.1 TLSv1.2;
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
ssl_prefer_server_ciphers on;
client_max_body_size 4G;
keepalive_timeout 10;
}
問題在這里
try_files $uri $uri/ /wordpress/index.php?$args;
root /var/www/wordpress;
您的try_files
行說要查找請求的文件,如果找不到該文件,請檢查它是否是目錄,如果該目錄也不起作用,則提供根目錄+ /wordpress/index.php?$args
,即/var/www/wordpress/wordpress/index.php?$args
對於Wordpress,這應該有效
try_files $uri $uri/ /index.php;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.