Installing CakePHP 3 On Digital Ocean Ubuntu 14.04

Summary

  • How to install  a CakePHP 3 app on a new droplet running Ubuntu 14.04.

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.

 

Installing Composer

First, update you package manager:

Install cURL:

You’ll be asked if you want to use the extra space, type ‘yes’ and hit enter.

Finally, install composer:

You should now be able to just type ‘composer’ and see the list of available commands.

Enable the rewrite module

Make sure the rewrite module is enabled

Restart the server:

Install the intl extension:

Restart the server:

Install Cake

This is all the requirements for CakePHP to run. We are now ready to 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:

You can now use composer to setup your project, giving your application some kind of relevant name:

You’ll be asked if you would like to set the folder permissions, type “Y” and hit enter.

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:

You’ll need to restart the server for the change to take effect:

Update The Web Root For Our Droplet

At the moment when we visit our droplet via a browser, we are taken to the “html” folder. If you look in the CakePHP 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):

Upload the modified file, replacing the old one. You’ll need to restart the server for the settings to take effect:

You should now be able to visit your droplet IP and see the default CakePHP page.

Debug Kit

Debug kit (the very useful debug toolbar that CakePHP comes with) is turned on by default in this initial installation, however,  it requires sqlite to be installed on our server for it to work.

To install sqlite run these few commands:

And finally restart the server one last time:

 

 

  • Kevin

    Extremely helpful, thanks a ton!

    • Hi @disqus_K0sWSobKYK:disqus, glad you found it useful. I’m working on a post to show how to setup the CRUD plugin (https://crud.readthedocs.io/en/latest/), it’s really cool if you haven’t seen it.

      It’ll show how you can easily use it to set up API JSON requests with very little work 🙂

      Kyle

  • Jose alexis Cruz Solar

    Gracias 😀 me sirvio para linux mint 18.1 Serena con XFCE 🙂