Jump to content

[SCRIPT] - Installing/using Prestashop and file permissions scripts for the lazy


Recommended Posts

Version : 1.0
Compatibility : Only for Linux/unix hosts
Author : Uddhava das

Info
I have been installing PS for too many times i can remember. So always i get stuck with manually changing all the needed file permissions during install.
Since the PS installer is not complete, many more files need some change of permissions.
So to make my life simpler i have written a shell script (linux/bash/ksh/sh) that does it for me.
So all you Apache/Linux ISP victims can use it so change the permissions easily.

Security
WARNING : Some files and dirs will be chmod to 777. If you have a ISP that uses shared hosting, (like mine) than apache runs as its own process for all users. Then your files and dirs will need to use 777 for Prestashop. When your ISP uses a local apache for each user (nice ISP) then chmod 777 is not needed.
"So choose wisely..."

Usage
* Unzip script and upload in the ROOT of your prestashop.
* make this script executable (chmod u+x)
* Run script

When you have changed your admin dir, then change this also in the script.

History
17 feb 2010 : Launched script to the world

Download

perms.zip

  • Like 2
Link to comment
Share on other sites

Ok dudes, here is the script in text form :

# Little script to setup the correct file/dir permissions
# You can use this during and after the install of prestashop
# 17 feb 2010 : Version 1.0
# Author : Uddhava das

# Are you sure?
read -p "Are you sure? " -n 1
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
   exit 1
fi
echo ""

# root files
echo "Change permissions on files AND Dirs of"
echo "config"
chmod 777 config
echo "sitemap.xml"
chmod 666 sitemap.xml
echo "tools/smarty/compile"
chmod 777 tools/smarty/compile
echo ""
echo "Change permissions on dirs only"
echo "Modules dir"
chmod 777 modules
echo "All subfolders in modules"
find modules/* -type d -print0 |xargs -0 chmod 777
echo ""

echo "import dir in /admin/import -> If you renamed your admin dir, then change this"
chmod 777 admin/import
echo "backup dir (/admin/import) -> If you renamed your admin dir, then change this"
chmod 777 admin/backup

chmod 777 upload
echo "All subfolders in upload"
find upload/* -type d -exec chmod 777 {} \;

echo ""
chmod 777 download
echo "All subfolders in download"
find download/* -type d -exec chmod 777 {} \;

echo ""
# Translations folder
echo "translations folder"
chmod 777 translations
echo "All subfolders in translations"
find translations/* -type d -print0 |xargs -0 chmod 777

echo ""
# Translations files.
echo "Change permissions of files in translations folders"
find translations/* -type f -exec chmod 666 {} \;
echo "except index.php"
find translations/* -name index.php -exec chmod 644 {} \;

echo "mails folder"
chmod 777 mails
echo "mails subfolders"
echo "All subfolders in mails"
find mails/* -type d -print0 |xargs -0 chmod 777
echo "img folder"
chmod 777 img
echo "All subfolders in img"
find img/* -type d -print0 |xargs -0 chmod 777

# Some loose files that need to have write permissions
echo "Some other files that need to be writable"
echo "logo in /img"
chmod 666 img/logo.jpg
echo "favicon.ico in /img"
chmod 666 img/favicon.ico
echo "editorial.xml file for home page"
chmod 666 modules/editorial/editorial.xml

echo ""
# Themes language files. ADD YOUR OWN THEME HERE
echo "themes folder and language files in folder"
echo "Add your theme here"
echo "lang folder to 777"
chmod 777 themes/prestashop/lang
chmod 777 themes/varsana/lang
echo "all files in lang folder to 666 "
chmod 666 themes/prestashop/lang/*
chmod 666 themes/varsana/lang/*

echo ""

# All language files in the modules folder. Add your language
echo "find all language files in modules folder and subfolders"
echo "Add new language if needed"
echo "Supported are en, es, fr and nl"
find modules/* -name en.php -exec chmod 666 {} \;
find modules/* -name es.php -exec chmod 666 {} \;
find modules/* -name fr.php -exec chmod 666 {} \;
find modules/* -name nl.php -exec chmod 666 {} \;
echo ""
echo "Done..."

Link to comment
Share on other sites

  • 2 weeks later...

Since 1.3.0.2 the permissions displayed in the installer are always correct.
That could mean that
1) Prestashop can now work without setting the permissions
2) My provider changed something

So did PS change something regarding the file permissions ?

Link to comment
Share on other sites

  • 4 weeks later...

This is a shell script that needs to be executed in a SSH session on your host.
It cannot be executed from Filezilla/ftp or control panels.

From your question can i deduce that you have never used unix/linux prompts before?
If so then do not use this script..

Link to comment
Share on other sites

  • 3 months later...
  • 3 months later...

It means you need to change 'admin' in these lines to whatever you renamed your admin directory to:

echo "import dir in /admin/import -> If you renamed your admin dir, then change this"
chmod 777 admin/import
echo "backup dir (/admin/import) -> If you renamed your admin dir, then change this"
chmod 777 admin/backup

Link to comment
Share on other sites

  • 1 month later...
  • 7 months later...
  • 2 years later...

This is a shell script that needs to be executed in a SSH session on your host.

It cannot be executed from Filezilla/ftp or control panels.

 

However, im writting because im looking not for an "setup and patch" permissions script. Im searching for a table with all permisions needer for all files/folders in prestashop 1.4 & 1.5 to correct some "wrong instalations or corrupted by som sysadmin :)".

 

I will make my own sh, or php (and post here of course) file for correct it, but dont know where is a relationship about permissions.

I only need special ones, like 666, or 777.

For all other one I use a "find & set" script to set 664 to files and 755 to folders.

 

Anyone know?

 

Regards.

Edited by wippa (see edit history)
Link to comment
Share on other sites

  • 1 year later...

Than you! It's works very well..

 

One problem that others peoples will get is owner of folder, to solve make a 

chown www-data:www-data -R your_folder_master_of_prestashop

. Remember that ww-data is a user example of Apache, but in each case look for the right user to do.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...