Install CakePHP 3 On Ubuntu 16.04 Digital Ocean

This guide assumes you’ve set up a Ubuntu 14.04 server and have MYSQL up and running. This guide uses the “PHPMyAdmin” from the “One Click Apps” available on Digital Ocean running on a droplet running Ubuntu 16.04. The smallest memory (512mb) should be enough to get you up and running.

If you don’t have a Digital Ocean account (you should, they’re a great service) get one here.

Step 1: Update Package Manager

Fire up a new terminal window and ssh into you’re droplet:

Note: If this is the first time you’ve logged into your droplet, you will be asked to change the password from the one emailed to you when you created your droplet. This is fairly self explanatory, simply follow the prompts.

Update your package manager:

Step 2: Install Some PHP Modules

We need to install a few PHP modules that CakePHP uses. Namely the curl, zip, intl and sqlite modules.

Run these commands in succession. You may be asked if you want to take up the extra space, reply ‘Y’ for yes:


Step 3: Install Composer

Composer is a dependancy manager for PHP, this is ultimately what we’ll use to install CakePHP to our server:


Step 4: Enable Rewrite Module

Make sure the recite module is enabled:


Step 5: Restart Apache

For all the changes we’ve made to actually take affect, we need to restart our server:


Step 6: Enable AllowOverride

Navigate to the ‘/etc/apache2’ directory, download and open the ‘apache2.conf’ file. Around line 166 within the ‘<Directory /var/www/>’ tags, change the that says ‘AllowOverride None’ to:

This allows .htaccess files to override of the Apache config on a per directory basis, which is what CakePHP needs.

You’ll also need to restart apache again for this change to take affect:


Step 7: Install CakePHP

Update 2/1/2018:

Digital Ocean now let you resize droplets by either CPU & RAM only or Disk, CPU & RAM. The former is reversible, meaning that you can upgrade your droplets RAM (which is what we’re short of here) and then decrease it after the install to step back on to the cheapest payment plan. I would highly recommend this approach.

During the following composer command it’s possible that it will fail due to the limited RAM available on the smallest droplet size, if this happens, update your droplet CPU & RAM quickly. Then revert it back at the end of the installation. 

Finally, we’re at the point where we can actually install CakePHP. We’ll use composer to download and setup our application. First off we need to change to the directory that we want it installed to. This will most likely be your public folder:

Note: Change YOUR_APP_NAME to something applicable (no spaces):


Step 8: Update The Web Root For Your Droplet

At the moment when we visit our droplet via a browser, we are taken to the ‘html’ folder (currently displays the default apache page). If you look in the folder you created in the previous step, there is a ‘webroot’ folder. This is actually the folder we need to point our droplet to. We can do this in one of the apache config files.

Navigate to the ‘/etc/apache2/sites-enabled’ directory and download and open the ‘000-default.conf’ file. You need to just change one line (around line 12):

Note: Again, change YOUR_APP_NAME to whatever you used in the previous step.

Re-upload this from whence it came overwriting the old file. Finally give apache one last restart for that to take affect:


If you visit your droplet IP in a browser, all being well, you should now see the default CakePHP.



You should see an abundance of green under ‘Environment’, ‘Filesystem’ and ‘DebugKit’. The ‘Database’ will show an error as we haven’t set one up yet and edited the CakePHP config file to tell it where to look for our database. You’ll need to setup a database and then edit your config.php file details can be found on how to do that in the CakePHP documentation here.


As we’re running our cake setup and developing on a server as opposed to a local environment, we’ve uploaded the cake shell script used to generate the scaffolding code for our database. This lives in the ‘bin’ directory. You’ll need to give this file write and execute permissions: