apache - Symfony 3.4 Apache Permission WebServer unable to write file in folder non writable
问题描述
I'm running Symfony using Apache WebServer instead of built-in webserver, in order to switch from dev to production environment, following theses official instructions: https://symfony.com/doc/current/setup/web_server_configuration.html
When I try to upload an image to my site folder I got
Unable to write in the
"/var/www/html/site/src/../public/front/cms/explanatory_rubric" directory
When I was running using Symfony built in server, using the port 8000 it was working and my folder was writable. I know it's a trouble with Apache Permissions. There are a lot of questions about that and I read carefully each of them, specially this one, explaining good practices about file permissions with Apache,and this one, this one, this one,and this one, etc
When I check my chmod owner non-writable folder I get:
ls -l
total 4
drwxr-xr-x 3 root www-data 4096 Jun 1 11:38 explanatory_rubric
I changed the chmod owner of the folder from www-data to root to give a write permission.
I also tried to give permission via my Apache configuration file.
This is my Apache configuration for 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>
解决方案
已解决:我将 chown 从 ubuntu 更新为 www-data,并授予特定文件夹的 chmod 权限:我还注意到,在symfony/apache-pack包的index.php中,我们可以找到一个umask(000),它可能是我烦恼的根源
我解决它的命令是:
chown www-data:www-data -R /my/folder # with Apache2
chown apache:apache -R /my/folder # with Apache
chmod -R 777 /my/folder
推荐阅读
- vb.net - 如何在 VB.Net 数据网格中禁用单元格编辑?
- prestashop - 提取产品的所有类别 ID
- angular - 使用 Firebase 使用本地化部署 Angular 10 应用
- html - 使元素高度整页
- css - 是否可以使用 CSS 定义可在类中使用的指定颜色值列表?
- c# - 使用 ASP.NET Core 和 SQL Server 在传单地图上动态添加标记
- html5-canvas - 通过画布在 antmedia 直播中嵌入 logo
- javascript - 如何将:“Cookies EU 横幅”添加到 Rails 6 站点
- c# - 如何在 UI 上显示经过净化的表情符号?
- python-3.x - 在 np.fromfunction 中使用带有 if 语句的 lambda 函数,具体取决于 `i` 和 `j`