Magento 2.1 – Fix Installation Permissions Issue

file-permissionsinstallationmagento-2.1magento-2.1.3permissions

I am stuck in the installation of new copy of Magento 2.1.3. I downloaded tar.bz2 archive from the site into the apache root folder of my CentOS 7 machine. I extracted it with the command

tar jxf Magento-CE-2_1_3_tar_bz2-2016-12-13-09-10-13.tar.bz2

when I was logged as the root user. Then I executed the permissions commands as Magento dev docs suggests:

find var vendor pub/static pub/media app/etc -type f -exec chmod u+w {} \;
find var vendor pub/static pub/media app/etc -type d -exec chmod u+w {} \;
chmod u+x bin/magento

Then, I finally navigated to http://mycentosurl/magento2, but what I get is not the wizard installation but this error:

Uncaught exception 'Magento\Framework\Exception\FileSystemException' with message 'The file "/var/www/html/magento2/var/.regenerate" cannot be deleted

What am I doing wrong?

Best Answer

Did you set the permissions while being logged in as root? Which user is your apache running with? If www-data is the user apache is using, it doesn't seem to have necessary permissions on var.

If it's just your local installation, you can do the following as root user in apache basedir:

chmod uog+rwx var pub/static pub/media
chown www-data:www-data var pub/static pub/media

This makes the necessary folders globally accessible. For the second line you need to know the user apache is running with. The example above is the default setting of apache. Don't use these settings in production.

Related Topic