Wednesday, August 11, 2010

Quick guide on setting up a CakePHP project (updated for 1.3)

This blog describes installing for CakePHP 1.3. It is an updated version of my previous guide.

1. Create database

First we create a database called cake13. Rename it as needed, but be sure to change it in the examples below.
user@host:~$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3890
Server version: 5.1.37-1ubuntu5.4 (Ubuntu)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> create database cake13;
Query OK, 1 row affected (0.00 sec)

-> ON cake13.*
-> TO 'cake13user'@'localhost' IDENTIFIED BY 's3cr3t';
Query OK, 0 rows affected (0.00 sec)

mysql> exit

2. Download CakePHP

Next we download the latest CakePHP from The version used in this example is 1.3.3 and the file cakephp-cakephp-1.3.3-43-gd1028a7.tar.gz is placed in the homedir.

3. Extract download

CakePHP will be installed in the ~/public_html/cake13 directory, which is served using mod_userdir. The directory will be available at the URL http://yourhost/~username/cake13 . Of course it is possible to install it to another location, but be sure to change the locations in the commands below accordingly.
Make sure mod_rewrite is working and that the AllowOverride property for ~/public_html is set to All.
user@host:~$ cd ~/public_html
user@host:~/public_html$ tar xvzf ~/cakephp-cakephp-1.3.3-43-gd1028a7.tar.gz
.  SNAP  .
user@host:~/public_html$ mv cakephp-cakephp-d1028a7/ cake13
user@host:~/public_html$ cd cake13/

4. Configure the database

Rename the default database config.
user@host:~/public_html/cake13$ mv app/config/database.php.default app/config/database.php
Edit the file freshly renamed file and change the values of the database configuration '$default' to match those on your system (you should probably change the values for login, user, password).
user@host:~/public_html/cake13$ vi app/config/database.php

5. Edit the core configuration file

Open the file app/config/core.php and edit the settings of 'Security.salt' and 'Security.cipherSeed'  (I always search for the word 'salt'). Change the strings by entering a new line of random characters, or by changing the existing ones. Note that the value of Security.salt can be alphanumeric, while Security.cipherSeed just uses digits..

user@host:~/public_html/cake13$ vi app/config/core.php

Set Permissions

The tmp dir needs write permissions. Use chmod -R 777 only in development environments. In production environments the owner of the files need to be the user running the webserver.
user@host:~/public_html/cake13$ cd app/
user@host:~/public_html/cake13/app$ chmod -R 777 tmp/
user@host:~/public_html/cake13/app$ cd ..

The CakePHP installation should now ready and available.

Please use the comments if you have any questions or comments :)

1 comment:

php development said...

I have seen a extremely informative blog. Truly I like this blog. This blog gives us especially excellent knowledge about CakePHP .