Reputation: 45
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>
Upvotes: 0
Views: 1321
Reputation: 45
Solved: I updated chown from ubuntu to www-data, and I give the chmod permission to the specific folders: I noticed also that in index.php from symfony/apache-pack pack we can find a umask(000) which can may be the origin of my troubles
My command to solve it was:
chown www-data:www-data -R /my/folder # with Apache2
chown apache:apache -R /my/folder # with Apache
chmod -R 777 /my/folder
Upvotes: 1