无法使用chroot wordpress获取静态文件

我试图用php-fpm和mysqlconfigurationchroot。 我设法解决,但是当我试图达到除index.php以外的文件(如CSS,PNG等),它不断给404。

但是,当我禁用chroot时,它工作%100正确。

我的目录结构是这样的;

/var/www #my chroot directory /var/www/tmp #related pid and sock files /var/www/log #related log directory /var/www/public_html #wordpress directory 

而我的nginxconfiguration是这样的;

 server { listen 80; ## listen for ipv4; this line is default and implied root /public_html; index index.php; server_name _; location / { index index.php; } if (!-e $request_filename) { rewrite ^.*$ /index.php last; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /public_html; } location ~ \.php$ { fastcgi_pass unix:/var/www/tmp/php5-fpm.sock; fastcgi_index index.php; fastcgi_param APPLICATION_ENV production; include fastcgi_params; } location ~ /\.ht { deny all; } } 

你觉得我做错了什么?

谢谢

我假设你正在使用PHP-FPM的chroot指令来应用chroot环境。 也就是说,nginx没有在chroot中运行。

如果是这样的话,问题是你的根configurationvariables在nginxconfiguration。

你应该使用:

 root /var/www/public_html; 

然后,在FastCGIconfiguration部分,你应该在include fastcgi_params之后添加这些行:

 fastcgi_param SCRIPT_FILENAME /public_html$fastcgi_script_name; fastcgi_param DOCUMENT_ROOT /public_html; 

这样,nginx使用真正的非chroot目录结构,而PHP-FPM使用chroot环境,并从根据chroot调整的nginx获取其环境信息。