Codeigniter - setting up directories and files permissions (chmod settings)

itsme picture itsme · Jul 13, 2013 · Viewed 27.2k times · Source

Since i don't think i got right permissions all over my application folders and files is there anyway to check the right permissions allover them?

I mean, does anyone knows/has a standard/tutorial/link to follow for Codeigniter to set chmod permissions?

thanks, any help appriaciated!

NB: when i say allover i mean from the root to all files the application & system folders contains

Also to specify little bit, i think i got problems with permissions, cause i passed my application through different OS and for example macosx setted different permissions on directories than windows etc... so it's sort of a hell actually

This is my app schema:

/project
   /application
   /system
   /css
   /img
   /vendor
   index.php
   .htaccess

Answer

Tim Post's Sock Ape picture Tim Post's Sock Ape · Jul 13, 2013

You want to:

chmod -R 0644 application system index.php

Assuming that CI is installed in the web root, with the application/ and system/ directories residing therein, which is the default setup.

What I typically do is put the application/ and system/ directories outside of the web root when I use Codeigniter, at which point you need to edit your index.php file to reflect that:

$system_path = '../system';
$application_folder = '../application';

Note, you'd be adding the ../ (and also need to move those directories one level down) but I digress. The permissions for each directory should be 0755 and for each .php file 0644, wherever you end up putting them. This includes any vendor, 3rdparty, sparks, etc, and any custom asset locations.

If using a templating engine of some sort, good setups will work with 0755 folder permissions at the location where the engine writes its output and intermediate output if applicable. If you find that breaking, find a host that supports suexec so that you don't have to make those locations 777 (or world writeable).

This is most easily done using a terminal (SSH), but should also be easily possible with whatever file manager thingadongdong your host provides.