【发布时间】:2017-11-04 08:45:07
【问题描述】:
我已经安装了一个新的 Ubuntu 16.04 服务器并使用 this 指南启用了 PHP-FPM。我还启用了userdir 模块(这样我就可以在/home/$user 下的public_html 文件夹中运行虚拟站点)和mod_ruid2。
根据第一个指南必须做的事情之一是将这三行添加到 000-default.conf 中:
<FilesMatch "\.php$">
SetHandler "proxy:fcgi://127.0.0.1:9000/"
</FilesMatch>
添加树线后,我的 conf 文件如下所示:
<VirtualHost *:80>
ServerName jrrtest
RMode stat
ServerAdmin webmaster@localhost
DocumentRoot /home/jrr/public_html
ErrorLog ${APACHE_LOG_DIR}/jrrtest-error.log
CustomLog ${APACHE_LOG_DIR}/jrrtest-access.log combined
<FilesMatch "\.php$">
SetHandler "proxy:fcgi://127.0.0.1:9000/"
</FilesMatch>
</VirtualHost>
PHP 现在按预期执行,但是当我尝试使用 this 页面上的示例上传文件时,它无法正常工作。如果我尝试上传文件,我会在 Apache error_log 中收到此错误:
PHP Warning: move_uploaded_file(uploads/jorara.png): failed to open stream: Permission denied in /home/jrr/public_html/upload.php on line 38\nPHP message: PHP Warning: move_uploaded_file(): Unable to move '/tmp/phpAJsos1' to 'uploads/jorara.png' in /home/jrr/public_html/upload.php on line 38
如果我从 000-default.conf 中删除 FilesMatch 行,则上传功能再次起作用,但 php 不再按照我的意愿使用 FastCGI 执行。
如果我重新启用 FilesMatch 行并将上传文件夹的所有者更改为 www-data:www-data,我也可以使用上传功能。
如何配置 PHP-FPM 以便 php 脚本的所有者可以将文件上传到与脚本所有者相同所有者的文件夹中?
问候, 约根
【问题讨论】:
-
什么
FilesMatch lines?it is not working是什么意思 - 错误消息、日志消息是什么? -
我所指的 FilesMatch 行可以在我链接到 (server-world.info/en/note?os=Ubuntu_16.04&p=httpd&f=16) 和
not working的第一个指南中看到我的意思是当我尝试上传一个错误时文件。 Apache error_log 中的错误是PHP Warning: move_uploaded_file(uploads/jorara.png): failed to open stream: Per mission denied in /home/jrr/public_html/upload.php。 -
编辑您的问题并添加这些详细信息。您提供的所有细节越细心,您将获得更好的响应。没有人会去阅读教程以了解您在做什么。
标签: php apache file-upload