php - Symfony can't write in cache folder on CentOS 7 even with the right permissions
Get the solution ↓↓↓Symfony cannot write in cache folder even i give full permissions to that folder
chmod 777 -R /path/to/symfony/var
But I am always getting these error
Cache directory "/path/to/symfony/var/cache/dev" is not writable.
I am on Centos 7 and I use nginx and php7
I never had this problem on Ubuntu or Windows. It's just when i moved my application to CentOS
One suggest to me to run those commands on the var folder
chcon -R -t httpd_sys_content_rw_t /path/to/symfony/var
systemctl restart nginx
This solution worked once. But after a while i got the same problem. I tried to re-run tose commands but nothing changed.
Any ideas?
Answer
Solution:
I've solved this issue. Here is how.
First, Nginx and php-fpm are running using the nginx user. This user is created automaticlly when installing Nginx.
On the/etc/nginx/nginx.conf
user nginx;
And on the/etc/php-fpm.d/www.conf
user = nginx
group = nginx
...
...
listen.owner = nginx
listen.group = nginx
listen.mode = 0660
Second the permissions on the symfony app are set to 755 and the owner is changed to nginx user/group (The user Nginx and php-fpm are using)
sudo chown -R nginx:nginx /path/to/symfony
sudo chmod 0755 -R /path/to/symfony
Then, I run two commands. The first is to ennable the httpd connections And the second allows the httpd process to read and write on the /path/to/symfony folder
sudo setsebool -P httpd_can_network_connect on
sudo chcon -R -t httpd_sys_content_rw_t /path/to/symfony
Finanlly, restarting the Nginx service
sudo systemctl restart nginx
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: err_ossl_pem_no_start_line
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.