Magento File Permissions

Posted June 26th, 2015 in Computers
The following error is received when you want to install a package:

Error: Please check for sufficient write file permissions
Your Magento folder does not have sufficient write permissions, which this web based downloader requires.

This is very non-descript - without knowing which files need to be changed, your only option is to set write permissions on the whole folder - which can be very fiddly to back out of.

In my experience, the files that need to be writable so the downloader can work are as follows. Make a note of what the permissions are before you start.

downloader (chmod 777)
downloader/config.ini (chmod 666 - if it exists)
downloader/pearlib/config.ini (chmod 666 - if it exists)
downloader/pearlib/php (chmod 777)
downloader/pearlib/download (chmod 777)
app/etc (chmod 777)
var (chmod 777)
media (chmod 777)
media/import (chmod 777)
media/downloadable (chmod 777)

SSH copy/paste commands

chmod 0777 downloader
chmod 0666 downloader/config.ini
chmod 0666 downloader/pearlib/config.ini
chmod 0777 downloader/pearlib/php
chmod 0777 downloader/pearlib/download
chmod 0777 app/etc
chmod 0777 var
chmod 0777 media
chmod 0777 media/import
chmod 0777 media/downloadable

Remember to change these back so they are non-writable when you are finished (this is especially important for the directories).

Changing Magento file permissions using the command line

If you have access to the command line, the following command will change folder permissions recursively. From within the Magento folder while in SSH, enter the following command:

find ./ -type d -exec chmod 777 {} ;

When you have finished installing, change permissions back:

find ./ -type d -exec chmod 755 {} ;

Set chmod on specific folders so they can be uploaded to:
chmod 777 var
chmod 777 media
chmod 777 app/etc


When trying to install modules, you may receive this error. It is very non-descriptive, and could be caused by several reasons. A search of Google will bring up a lot of questions but not many answers on this subject. The answer can be your firewall, or file permissions. However, if you have two magento installs on the same system and installing modules on one works, but the other doesn''t - you know it''s not the firewall.

One of our installs returned the INVALID POST DATA error when trying to install a module. On this particlar site, the chmod of pear was wrong. This was the ''pear'' file within the magento install folder, not system pear. Set the chmod on the ''pear'' file to 755.

After setting the chmod on ''pear'', if this doesn''t fix the problem, run mage-setup. This needs to be performed from within SSH. From within the magento install directory (the one with index.php) type the following:

./pear mage-setup

This will not destroy files or your database. After running this command, the downloader worked fine. Take notice of other errors that occur and rectify them as needed - these may include further file permission errors.

Magento cron returns error 'Undefined index: SCRIPT_NAME'

To automatically send newsletters to subscribers in Magento, I found the code to set up a cron job. I copied and pasted this code into the crontab file, after which the newsletters did not send and I received an email every time cron ran informing me of the following:

Notice: Undefined index: SCRIPT_NAME in [path removed]/public_html/cron.php on line 36

Notice: Undefined index: SCRIPT_FILENAME in [path removed]/public_html/cron.php on line 37

Fatal error: Uncaught exception ''Zend_Db_Adapter_Exception'' with message ''pdo_mysql extension is not installed'' in [path removed]/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php:178

This was perplexing - I checked phpinfo() and pdo_mysql was enabled, and if cron.php was called via a browser, there was no error. The issue seemed to be realated to pdo_mysql not being available to the command line. After much digging into what needed to be changed to be able to access pdo_mysql via the command line, it became apparent that the command used to call PHP did not contain the full path the PHP:

*/5 * * * * php /path_removed/public_html/cron.php

Obviously, this caused the script to run with a different version of PHP than expected. I changed the cron entry to include the full path, and presto! No more cron error emails.

*/5 * * * * /usr/local/bin/php /path_removed/public_html/cron.php


No comments

Leave a comment