I recently set up a new Linux (CentOS 7) box as a Magento development environment for one of our clients. I was primarily interested in using Magento Connect to do an upgrade from Magento 1.9.2.2 to Magento 1.9.2.3. When I tried to use the Magento Connect Manager, however, I immediately started running into issues. I kept getting the warning message, Warning: Your Magento folder does not have sufficient write permissions and wasn’t able to continue.
After Googling numerous times, and verifying my file permissions, and apache and php configurations, I still wasn’t able to solve the problem. Everything seemed to be configured correctly!
So, I created a simple php script to help me figure out what was going on:
<?php
echo `whoami`;
file_put_contents(‘/var/www/html/magento/var/log/test.txt’,’hello’,FILE_APPEND);
?>
The result was that the php process was indeed running as apache, and that I wasn’t able to write to the test.txt file. I was able to see the errors being generated in the php error log as:
[Wed Jan 27 11:50:09.557315 2016] [:error] [pid 15256] [client 192.168.1.112:57119] PHP Warning: file_put_contents(/var/www/html/magento/var/log/test.txt): failed to open stream: Permission denied in /var/www/html/magento/testing.php on line 4, referer: http://centos.trl.local/magento/testing.php
Armed with this information, I started searching Google again, and came up with this post, which lead me to this post. After following the instructions found here, I was able to continue with my upgrade.
Commands used to resolve my file permission issue:
#getenforce
Enforcing
#cd /etc/selinux
#cp config config.orig
#vi config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing – SELinux security policy is enforced.
# permissive – SELinux prints warnings instead of enforcing.
# disabled – No SELinux policy is loaded.
#SELINUX=enforcing
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
# targeted – Targeted processes are protected,
# minimum – Modification of targeted policy. Only selected processes are protected.
# mls – Multi Level Security protection.
SELINUXTYPE=targeted
#setenforce 0
(no need to reboot)
I hope this helps someone else!