Preparing a CakePHP environment

After a quick look at Ruby on Rails, I decided to have a turn with CakePHP.

On the whole, CakePHP is much easier to install and configure than Ruby on Rails. There are fewer abstractions to get out of the way: I'm already familiar with PHP, I don't have to wrestle with Gems, and it works out of the box with Apache and MySQL.

Installing CakePHP is, well, a piece of cake. It works with a standard Apache, MySQL, and PHP stack. After that, just a few more steps:

First, enable mod_rewrite:

sudo a2enmod rewrite

Next, edit /etc/apache2/sites-enabled/000-default. This is the configuration file for Apache. The key changes are AllowOverride All directives. A sample from my configuration file:

<VirtualHost *:80>
ServerAdmin webmaster@localhost

DocumentRoot /var/www/
<Directory />
Options Indexes FollowSymLinks
AllowOverride All
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all

Then, restart the Apache web server.

sudo /etc/init.d/apache2 restart

At this point, the /var/www directory will now be ready to receive CakePHP applications.

But what is a CakePHP application? It begins with the CakePHP web application framework. Download it from the CakePHP web site. The framework provides the basic structure for the application.

Unzip the file in /var/www and rename the directory to whatever name your application will have. (Make sure that the directory is owned by user www-data and group www-data.)

There's some more configuration that's needed within the CakePHP application itself, but you can read through that in the Cake documentation and tutorial.