【发布时间】:2018-11-11 13:43:55
【问题描述】:
我正在使用 Apache WebServer 而不是内置的网络服务器运行 Symfony,以便从开发环境切换到生产环境,遵循这些官方说明: https://symfony.com/doc/current/setup/web_server_configuration.html
当我尝试将图像上传到我的站点文件夹时,我得到了
Unable to write in the
"/var/www/html/site/src/../public/front/cms/explanatory_rubric" directory
当我使用 Symfony 内置服务器运行时,使用端口 8000 它正在工作并且我的文件夹是可写的。 我知道 Apache 权限有问题。对此有很多问题,我仔细阅读了每个问题,特别是 this one,解释了有关 Apache 文件权限的良好做法,以及 this one、this one、this one 和 this one 等
当我检查我的 chmod 所有者不可写文件夹时,我得到:
ls -l
total 4
drwxr-xr-x 3 root www-data 4096 Jun 1 11:38 explanatory_rubric
我将文件夹的 chmod 所有者从 www-data 更改为 root 以提供 写权限。
我还尝试通过我的 Apache 配置文件授予权限。
这是我的 Apache SSL 配置:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName www.mysite.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
<Directory /var/www/html/site/public>
AllowOverride All
Order Allow,Deny
Allow from All
</Directory>
<Directory /var/www/html/site/public/front/cms/explanatory_rubric>
AllowOverride All
Order Allow,Deny
Allow from All
</Directory>
【问题讨论】:
-
您好,我相信 Apache 在通过浏览器访问应用程序时始终使用 www-data 作为用户,因此 www-data 需要对您的应用程序文件夹具有写入权限。
-
好的,所以我必须在我的 Apache 配置中声明目录?为什么我的配置实际上无法授予对该文件夹的写访问权限?感谢支持
标签: apache symfony chmod chown