• Home  / 
  • PHP
  •  /  Installing CakePHP 3 on Dreamhost Shared Hosting

Installing CakePHP 3 on Dreamhost Shared Hosting

By zhunt / 9th October, 2017

I’ve used Dreamhost for several years for WordPress blogs, static blogs and a number of CakePHP 2 projects over the years. But because CakePHP 3 needs some non-default extensions running, I assumed would be require a dedicated server as opposed to a shared host, something that a bit of Googling seemed to confirm – turns out it’s not.

if you’ve been around web development for a while, Dreamhost had a less than stellar reputation back in the early days, but I think they’ve improved a lot and they have a pretty straightforward interface for people like me who try to avoid server config files when possible. For instance, it early on had Google Apps integration (they handle updating the MX records for you), CloudFlare, and since this year, nearly automatic set-up of Lets Encrypt, which gives you SSL in a few clicks, and something that is almost a must-have these days.

Getting CakePHP Running:

First thing is to set up your domain and then setting the PHP version. Pick the newest version of PHP, at this time it’s PHP 7.1

CakePHP 3 is currently tested up to 7.1 or even 7.2, so go ahead and pick the version you prefer. There is a PHP 5.6 available from the drop-down, but with 7 you get roughly twice the speed, so what not use it?

Next, CakePHP 3 needs some extensions, specifically the mbstring, intl, and simplexml PHP extensions.

To load in the extensions, we need to create a phprc file, DreamHost has a good tutorial here. Basically a phprc file lets you override some of PHP’s configuration setting. In this case we’re just making sure it loads some extensions:

# phprc  file for CakePHP
extension = php_mbstring.so
extension = intl.so
extension = simplexml.so

That’s really all there is to it. I did try using CakeDC’s Oven, but while it did confirm that all the extensions where being found, it seemed to stop running at the point where it tried to install Composer; I’m assuming it’s something with the account’s remote downloading not configured, so what I ended up was running:

composer create-project --prefer-dist cakephp/app cakeapp

on my Windows machine and FTPed up the files composer generated. For the database, DreamHost has a section under “goodies” to create and manage MySQL. You can copy the database credentials over to the app.php file in (the default ports in app.php all seemed to work for me, just remember to change the host from “localhost” to whatever you set it up to be) and you should see the familiar CakePHP welcome screen. At the time of writing, they only support MySQL 5.6 (not sure when 5.7 or higher support is coming), though some users have set-up other databases on DreamHost’s DreamCompute service.

That’s it, you should now have server running CakePHP 3, that can be easily upgraded to CDN support (CloudFlare) and SSL.

 

 

 

 

 

About the author

zhunt

Click here to add a comment

Leave a comment: