Magento Server Setup – How to Set Proper Permissions for Magento

magento-1.8permissionsserver-setup

I'm getting lot of issues with permissions.

In magento admin panel:

Your web server is configured incorrectly. As a result, configuration files with sensitive information are accessible from the outside. Please contact your hosting provider.

When I upload images from cms:

The directory is not writable by server.

If anyone access this url: http://example.com/app/etc/modules/

they can see easily configuration settings.

Using FTP account: I'm not able to override any file and some times I'm not able copy any local folder to server through FTP.

My application place is /var/www/html.

with senior developer advice I execute following commands:

find <foldername> -type d -exec chmod 755 {} \; 
find <foldername> -type f -exec chmod 664 {} \;

and below are present permissions for each folder.

drwxr-xr-x 12 root     root     4096 Jun 10 13:06 var
drwxr-xr-x  3 root     root     4096 Jun 10 13:06 www
drwxr-xr-x 15 www-data www-data 4096 Jun 18 07:29 html

root@web-server-magento:/var/www/html# ls -l

total 14644
-rw-rw-r--  1 www-data www-data     2834 Nov 26  2013 api.php
drwxr-xr-x  6 www-data www-data     4096 Jun 17 11:16 app
-rw-rw-r--  1 www-data www-data     2831 Nov 26  2013 cron.php
-rw-rw-r--  1 www-data www-data      717 Nov 26  2013 cron.sh
-rw-rw-r--  1 www-data www-data  2454234 Oct 26  2011 data.sql
drwxr-xr-x  8 www-data www-data     4096 Jun 11 07:21 downloader
drwxr-xr-x  3 www-data www-data     4096 Nov 26  2013 errors
-rw-rw-r--  1 www-data www-data     1150 Nov 26  2013 favicon.ico
-rw-rw-r--  1 www-data www-data     5979 Nov 26  2013 get.php
drwxr-xr-x  2 www-data www-data     4096 Nov 26  2013 includes
-rw-rw-r--  1 www-data www-data    11510 Jun 10 13:06 index1.html
-rw-rw-r--  1 www-data www-data     2642 Nov 26  2013 index.php
-rw-rw-r--  1 www-data www-data     2366 Nov 26  2013 index.php.sample
-rw-rw-r--  1 www-data www-data     6441 Nov 26  2013 install.php
drwxr-xr-x 12 www-data www-data     4096 Jun 18 06:28 js
drwxr-xr-x 13 www-data www-data     4096 Nov 26  2013 lib
-rw-rw-r--  1 www-data www-data    10421 Nov 26  2013 LICENSE_AFL.txt
-rw-rw-r--  1 www-data www-data    10679 Nov 26  2013 LICENSE.html
-rw-rw-r--  1 www-data www-data    10410 Nov 26  2013 LICENSE.txt
-rw-rw-r--  1 www-data www-data    10327 Jun 11 14:48 logo.png
-rw-rw-r--  1 www-data www-data     1319 Nov 26  2013 mage
drwxr-xr-x 13 www-data www-data     4096 Jun 18 07:29 media
-rw-rw-r--  1 www-data www-data      886 Nov 26  2013 php.ini.sample
drwxr-xr-x  2 www-data www-data     4096 Nov 26  2013 pkginfo
-rw-rw-r--  1 www-data www-data   585086 Nov 26  2013 RELEASE_NOTES.txt
drwxr-xr-x  2 www-data www-data     4096 Nov 26  2013 shell
drwxr-xr-x  5 www-data www-data     4096 Nov 26  2013 skin
drwxr-xr-x  9 www-data www-data     4096 Jun 18 06:57 var

Please comment if any extra information needed.

Best Answer

Please check and verify below steps:

  1. Check if your server is compatible with Magento. Download file from this link Magento Server Compatibility check and follow the instructions given.

  2. Check for the .htaccess in each folder and in root too. Magento has .htaccess in almost all folders. Verify it for media folder in case the problem is with image

  3. Execute the following server commands going into your project folder:

    find ./ -type f | xargs chmod 644
    find ./ -type d | xargs chmod 755
    

    This gives 644 permission to files and 755 to folders.

  4. Next give 777 permission to var and media folder if the problem still persists, use the following commands for it:

    chmod -Rf 777 var
    chmod -Rf 777 media
    
  5. Also check the html folder permission of your server. It should be 755.

Hope this should resolve your problem.

Related Topic