How To Install CakePHP On An Ubuntu 12.04 VPS

Installing CakePHP There are a few ways you can install CakePHP on your server. You can download and unpack the archive from the CakePHP website, you can use Git to clone a release from Github or you can even use PEAR. We will use the first one as it is the most straightforward.

So what we need to do is download the latest stable release (link to which we can find on the CakePHP website home page) and unzip it into a folder. So let’s navigate to our web server’s root folder and download the archive:
cd /var/www

This will download a .zip file with the release version as the name. Now we need to unzip this file. If you don’t have unzip installed, just run the following command to quickly install it:
sudo apt-get install unzip

Now you’ll be able to unzip the archive (just make sure you replace the name of the .zip file with the one you have just downloaded):
unzip 2.3.9

You should get a new folder that contains all the CakePHP files. You can go ahead and rename this folder to something more useful, let’s say project:
mv cakephp-cakephp-4b9e390 project

Make sure again that you replace the name of the folder with the one you got after unziping the archive. And this command will rename it to project. So you currently have CakePHP found in the /var/www/project folder. You can find more information about the files and folder structure you’ll see in there.

Next up, let’s change the permissions of the app/tmp folder of your application as CakePHP will need to use it quite a bit so it needs to be writable by the webserver. For Apache, run the following commands from within the /var/www/project folder:
cd project
sudo chown -R root:www-data app/tmp
sudo chmod -R 775 app/tmp

This will change the ownership of the folder and everything inside it to the root user and www-data group (which contains the www-data user that Apache uses to run its processes). The second command then sets the folder permissions in a way in which the www-data group can write in it.
URL rewriting Let’s make sure that our webserver allows url rewriting as CakePHP works very nicely with clean URLs. This means that the Apache module mod_rewrite needs to be enabled and that the virtual host allows the .htaccess files to do their overriding. So first check if mod_rewrite is enabled on your system with this command:
sudo apache2ctl -M

If you see rewrite_module in the list, you are fine. If not, use the following command to enable the module:
sudo a2enmod rewrite

Next, if this is not the case for you, edit the Apache default virtual host file and make sure that Allow Overrides is set to All for the /var/www directory. Edit the file with the following command:
sudo gedit /etc/apache2/sites-available/default

And where you see this block, make the changes to correspond to the following:
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all

This will make sure that the .htaccess files can override the default Apache instructions. After any of these steps, make sure you restart Apache for the changes to take effect:
sudo service apache2 restart
Cakephp installation on ubuntu
other ref for cake php installation on ubuntu
one more ref


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s