Articles


Magento File Permissions Error

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:

Folder magento is installed in - may be public_html, or magento if you are using a subdirectory. If you change public_html - MAKE SURE YOU CHANGE IT BACK TO WHAT IT WAS ORIGINALLY!! THIS IS NOT755! 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).

UPDATE:

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

INVALID POST DATA



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.


And now for another one I spent a while on...


To automatically send newsletters to subscribers, 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 had me perplexed for a while - 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 crossed my mind that I should go back to the source and see how cron was calling the file. Sure enough - the line I pasted :


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


did not contain a full path to 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, which I take it to mean the cron is running successfully!


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



Valid XHTML 1.0!

There are 7 users online

1,095,250 total unique visitors
2,123,006 total pageviews
176 visitors in the last 24 hours
144 total visitors today
257 pageviews today
This page has been visited 35,037 times

Most users online at once:
52 on 12/13/2009