Installing CakePHP using SSH Client

CakePHP is a free open source framework which is used to develop rapid application using PHP. It is a MVC framework and it has an active friendly community from where you can take guidance too.

A lot of our users at Cloudways have been sending in requests to add CakePHP as a one-click application install. We are looking into that feasibility however, at the moment you can easily install any version of CakePHP on Cloudways using the SSH terminal. For this, you need to sign up on Cloudways Managed PHP Hosting and follow the instructions given below to install CakePHP on Cloudways.

After you have created an account with Cloudways, Select PHP Stack from the drop down and then fill up your Application name, Server Name and Select Default Project from drop down.

Then choose your desired cloud provider from Vultr, DigitalOcean, Amazon or Google and desired server size and location. Now click on Launch and wait for the server to start.

After the server is launched, rename your application to cakephp so it becomes easy for you to access it via SSH client. For this navigate to select Applications from the top menu, then select your application.

Now select Application Setting from the left side menu in your application and click on pencil below the Folder to rename it.

Launch your SSH Terminal

Now navigate to Servers from the top menu, click on your server and then from the left side menu select Master Credentials launch the SSH terminal.

Once SSH is launched, log in to it with your username and password provided in Master Credentials and type the following commands to reach your public_html

cd application
cd cakephp
cd public_html

How to Install CakePHP using Git

Now go to the git repository of CakePHP, copy the HTTPS and type the following command to install it.

git clone -b 2.7 git://github.com/cakephp/cakephp.git

To check whether cakephp is installed or not, copy the application url from Application Tab, paste it in to your browser and type /cakephp at the end of it. Your page should look like this:

Now, there are 2 errors which you see. One is that your database file is not configured and the second is, that the debug kit is not installed.

Enable Database Config file

First we need to rename the database file. For that, you need to perform the following commands on your SSH.

cd cakephp
cd app
cd Config
mv database.php.default database.php

Since we have renamed the database file, you need to reload the cakephp page and the error will be removed now.

Install Debug Kit

CakePHP recommends you to use its own debug kit to enhance CakePHP debugging and error reporting. Let’s get started. First you need to reach the main cakephp folder and then need to update it. Perform the following commands to reach the cakephp folder and install debug kit.

cd ..
cd ..
composer update

Once the update is complete, the debug kit will be installed in Plugin/DebugKit. We need to copy it inside the plugin folder in your app to use it. To do this type the following command.

cp -r Plugin/DebugKit app/Plugin

Now we need to configure your CakePHP to use it. For that connect it to your ftp server using filezilla or other software. Enter your ftp info, which can be found in Server Management tab under Master Credentials. First, you need to go to your cakephp folder inside public_html and then need to do the following steps to enable it.

Go to app/config/ open bootstrap.php in an editor and type the following line of code in it:

CakePlugin::load(‘DebugKit’);

Now open core.php in an editor and set debug to 1

Configure::write(‘debug’, 1);
  1. Now we need to include its toolbar in AppController for that go to app/Controller/ and open AppController.php and add the following line inside its controller
class AppController extends Controller {
public $components = array(‘DebugKit.Toolbar’); //Add this line
}

Now we need to remove sql dump to use the log of Debug kit only. For that goto app/View/Layouts/ and open default.ctp and comment the following line in it.

<?php //echo $this->element(‘sql_dump’); ?>

Now goto your cakephp link in the browser and you will find Debug kit enabled.

Now CakePHP is fully configured! What you can do more? You can configure your database with this and connect your domain with Cloudways and start using it. Cloudways is not only an affordable managed cloud hosting provider, but it is also the most robust platform that is built to withstand the maximum surge in traffic and greatly streamlines how you could install CakePHP. Sign up now and experience the difference in pageload times yourselves.


Originally published at www.cloudways.com on January 14, 2016.