Friday, July 31, 2009

Quick guide on setting up a CakePHP project

Read the updated version for CakePHP 1.3 here

Create the database

First we create a database called authcake. 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 385
Server version: 5.0.67-0ubuntu6 (Ubuntu)

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

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

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

mysql> exit

Download CakePHP

Next we download the latest CakePHP from The version used in this example is Stable and the file cake_1.2.3.8166.tar.gz is placed in the homedir.

Extract download

CakePHP will be installed in the ~/public_html/authcake directory, which is served using mod_userdir. The directory will be available at the URL http://yourhost/~username/authcake . 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 ~/cake_1.2.3.8166.tar.gz
.  SNAP  .
user@host:~/public_html$ mv cake_1.2.3.8166/ authcake
user@host:~/public_html$ cd authcake/

Configure Database

Rename the default database config and change the values to match those on your system.

user@host:~/public_html/authcake$ mv app/config/database.php.default app/config/database.php
user@host:~/public_html/authcake$ vi app/config/database.php

Update Configuration

Change the setting Security.salt in the core.php file

user@host:~/public_html/authcake$ 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/authcake$ cd app/
user@host:~/public_html/authcake/app$ chmod -R 777 tmp/
user@host:~/public_html/authcake/app$ cd ..

The CakePHP installation should now ready and available.

The result in the browser should look like this:

No comments: