1

I have a server dedicated to Magento 2, and followed the steps on the page below: http://devdocs.magento.com/guides/v2.1/install-gde/prereq/file-sys-perms-over.html

I didn't do the umask part of the following page since the page says, "We recommend changing the umask on a one-user or shared hosting system only". http://devdocs.magento.com/guides/v2.1/install-gde/install/post-install-umask.html

So, in short, I ran the following commands only regarding the permissions:

cd <your Magento install dir>
find var pub/static pub/media app/etc -type f -exec chmod g+w {} \;
find var pub/static pub/media app/etc -type d -exec chmod g+ws {} \;

Here are the permissions of the files after these steps:

drwxrwxr-x 12 magento2 apache   4096 Feb  6 04:05 .
drwxrwxr-x  4 root     root     4096 Feb  6 04:05 ..
drwxr-xr-x  4 magento2 apache   4096 Feb  6 04:05 app
drwxr-xr-x  2 magento2 apache   4096 Feb  6 04:05 bin
-rw-r--r--  1 magento2 apache 435065 Dec  9 06:33 CHANGELOG.md
-rw-r--r--  1 magento2 apache   1843 Dec  9 06:30 composer.json
-rw-r--r--  1 magento2 apache 344002 Dec  9 06:33 composer.lock
-rw-r--r--  1 magento2 apache   3381 Dec  9 06:33 CONTRIBUTING.md
-rw-r--r--  1 magento2 apache    631 Dec  9 06:33 COPYING.txt
drwxr-xr-x  5 magento2 apache   4096 Feb  6 04:05 dev
-rw-r--r--  1 magento2 apache   1116 Dec  9 06:30 .gitignore
-rw-r--r--  1 magento2 apache   2854 Dec  9 06:33 Gruntfile.js.sample
-rw-r--r--  1 magento2 apache   3235 Dec  9 06:33 .htaccess
-rw-r--r--  1 magento2 apache   9314 Dec  9 06:33 .htaccess.sample
-rw-r--r--  1 magento2 apache   1358 Dec  9 06:33 index.php
-rw-r--r--  1 magento2 apache    315 Dec  9 06:33 ISSUE_TEMPLATE.md
drwxr-xr-x  4 magento2 apache   4096 Feb  6 04:05 lib
-rw-r--r--  1 magento2 apache  10376 Dec  9 06:33 LICENSE_AFL.txt
-rw-r--r--  1 magento2 apache  10364 Dec  9 06:33 LICENSE.txt
-rw-r--r--  1 magento2 apache   5071 Dec  9 06:33 nginx.conf.sample
-rw-r--r--  1 magento2 apache   1427 Dec  9 06:33 package.json.sample
-rw-r--r--  1 magento2 apache   1617 Dec  9 06:33 .php_cs
-rw-r--r--  1 magento2 apache    804 Dec  9 06:33 php.ini.sample
drwxr-xr-x  2 magento2 apache   4096 Feb  6 04:05 phpserver
drwxr-xr-x  6 magento2 apache   4096 Feb  6 04:05 pub
drwxr-xr-x  7 magento2 apache   4096 Feb  6 04:05 setup
-rw-r--r--  1 magento2 apache    884 Dec  9 06:33 .travis.yml
drwxr-xr-x  7 magento2 apache   4096 Feb  6 04:05 update
-rw-r--r--  1 magento2 apache    101 Dec  9 06:33 .user.ini
drwxrwsr-x  8 magento2 apache   4096 Feb  6 04:06 var
drwxrwsr-x 29 magento2 apache   4096 Feb  6 04:05 vendor

Then, I issued the magento setup:install, and it finished without any errors, but the installer created some files with wrong permissions, which causes an error when accessing the site. Here are the permissions after running the installer:

$ ls -la var/cache/
total 24
drwxrwsr-x 6 magento2 apache 4096 Feb  6 04:06 .
drwxrwsr-x 8 magento2 apache 4096 Feb  6 04:06 ..
drwxrwxrwx 2 magento2 apache 4096 Feb  6 04:06 mage--1
drwxrwxrwx 2 magento2 apache 4096 Feb  6 04:06 mage--4
drwxrwxrwx 2 magento2 apache 4096 Feb  6 04:06 mage--9
drwxrwxrwx 2 magento2 apache 4096 Feb  6 04:06 mage-tags
$ ls -l var/cache/mage-tags/
total 12
-rw-rw---- 1 magento2 magento2   1 Feb  6 04:06 mage---504_CONFIG
-rw-rw---- 1 magento2 magento2  11 Feb  6 04:06 mage---504_CONFIG_SCOPES
-rw-rw---- 1 magento2 magento2 364 Feb  6 04:06 mage---504_MAGE

Here is the error message:

[2017-02-05 19:33:56] main.CRITICAL: Exception: Warning: file_put_contents(/path/to/magento2/var/cache//mage-tags/mage---504_CONFIG): failed to open stream: Permission denied in /path/to/magento2/vendor/colinmollenhour/cache-backend-file/File.php on line 663 in /path/to/vendor/magento/framework/App/ErrorHandler.php:61

I'm not sure which one should be fixed, either the installer or the documentation.

For those who experience the same issue, to work around this, I ran the chmod command again.

Related issues?

Environment:

  • CentOS 6.8
  • Apache 2.2
  • Magento 2.1.3

Thank you.

0

Please take a look at these answers How to set proper permissions for Magento on server?
You probably have these errors because you are not using the right user on the file permission

| improve this answer | |
  • I think you read only the title and the first few sentences. – k4200 Feb 6 '17 at 1:10

Not the answer you're looking for? Browse other questions tagged or ask your own question.