Saturday 13 October 2012

Changing file permissions of a folder and all of its subfolders and files in Ubuntu.

Changing file permissions in Ubuntu is a very essential thing. If proper file permissions are not set to folders or files, it is not possible to execute any PHP or HTML files from the browser using localhost. The following command can be used to set file permission for any file or folder.

sudo chmod 755 /var/www/myfolder

In the above example

    7 – Owner(current user)
    5 – Group(set by owner)
    5 – anyone else

To change the file permission for all the files and subfolders inside a folder the following command can be used:

sudo chmod 755 -R /var/www/myfolder 

0 – no permission, this person cannot read, write or execute
1 – execute only
2 – write only
3 – execute and write only (1 + 2)
4 – read only
5 – execute and read only (1 + 4)
6 – write and read only (2 + 4)
7 – execute, write and read (1 + 2 + 3)

CakePHP Tutorial:Installing CakePHP on Ubuntu

This is another cakephp on ubuntu. Most of them were not detail enough for beginners. So here I am and here is my version of installing cakephp on ubuntu.
  1. Install Apache Server, MySQL, PHP
    sudo apt-get install apache2 mysql-server php5
  2. Download CakePHP 1.2
    Go to http://cakephp.org and download latest cakephp. I downloaded cake_1.2.1.8004.tar.bz2
  3. Copy and extract to web root
    Open your terminal where you put cakephp you just downloaded.
    sudo cp cake_1.2.1.8004.tar.bz2 /var/www/
    cd /var/www
    sudo tar -xvf cake_1.2.1.8004.tar.bz2
    sudo mv cake_1.2.1.8004 cakephp
  4. Change tmp folder permisssion
    sudo chmod -R 777 cakephp/app/tmp
  5. Enable mod-rewrite
    sudo a2enmod rewrite
  6. Open file /etc/apache2/sites-enabled/000-default and change AllowOverride None to AllowOverride All
    sudo vim /etc/apache2/sites-enabled/000-default 
    <Directory /var/www/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
    </Directory>
    to
    <Directory /var/www/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>
  7. Restart Apache
    sudo /etc/init.d/apache2 restart
  8. Open your browser and type address http://localhost/cakephp/ and you’ll see CakePHP message
If you can see CakePHP message in colour, then you have cakephp running in your hand. Congratulation.