Run Craft CMS 3 on Cloud9
A tutorial to guid you on upgrading to PHP 7.0 and install Craft CMS on the Cloud9 IDE.
Craft CMS is the new kid around the CMS block. Check out these stats:
A number of people seem to love Craft CMS for some good reasons.
It’s only fitting to develop for an amazing CMS on an amazing Cloud IDE. We use Cloud9 for all our recent projects and love it because its so fast to setup new projects, clone and share existing ones and collaborate on code, to just name a few advantages of Cloud9.
If you haven’t signed up for Cloud9 yet, do it now!
It’s an amazing expirience and enables you to onboard new projects members by simply sharing an URL. Your collaborators don’t need to install or configure an IDE, Apache, PHP, MySQL or whatever stack you are using. Simply share the URL and they are ready to code along…
However, while setting up Craft CMS 3 Developer Preview on Cloud9, I ran into a few issues. This is how to get it working:
Create a new PHP, Apache container on Cloud9:
Download the latest Craft CMS beta to your instance.
Open a new terminal window (⌥ + T) and download and unzip Craft (The commands need to be executed without $):
$ wget https://download.craftcdn.com/craft/3.0/3.0.2948/Craft-3.0.2948.zip$ unzip Craft-3.0.2948.zip
As per the Craft CMS installation-guide, point your web directory to the public folder. To do this, edit your vhost configuration. I link it into the workspace folder to easily edit it with the Cloud0 editor (not a vim fan):
$ ln -s /etc/apache2/sites-enabled/001-cloud9.conf httpd.conf$ sudo chown ubuntu:ubuntu httpd.conf$ c9 open httpd.conf
Run the project — to run into problems
Don’t forget to Share the application on the upper right corner to access the front-end of your project. Then click the play icon and open the preview to see the app running:
Craft CMS requires PHP 5.6 or later…
After installing PHP 5.6 you’ll quickly find out that you ned some more things to get Craft CMS going. Namely:
- At least PHP 5.6
- PHP curl
- PHP mcrypt
- PHP mbstring
So let’s get to work and fix this…
Install PHP7.0 and the required php extensions on Cloud9
We are going to add the PHP 7.0 library and remove PHP 5 from the system. In your terminal type the following commands:
Add the repository containing the PHP 7.0 Library
$ sudo add-apt-repository ppa:ondrej/php -y
Updated the repository
$ sudo apt-get update -y
Install PHP 7.0 and required extemsions
$ sudo apt-get install php7.0-curl php7.0-dev php7.0-gd php7.0-intl php7.0-mcrypt php7.0-json php7.0-mysql php7.0-opcache php7.0-bcmath
php7.0-mbstring php7.0-soap php7.0-xml php7.0-mbstring
Install PHP7 Apache Module
$ sudo apt-get install libapache2-mod-php7.0 -y
Cleanup unused stuff
$ sudo apt-get autoremove -y
Deactivate PHP 5 module and acitvate php 7 module, then restart apache
$ sudo a2dismod php5; sudo a2enmod php7.0; service apache2 restart
Configure Craft CMS on Cloud9
If you now restart the application, you will still run into an error, no worries, Craft CMS needs some configuration:
In the public folder, rename the htaccess file to .htaccess:
$ mv public/htaccess public/.htaccess
Open the database configuration file:
$ c9 open craft/config/db.php
to match your cloud9 username and db like so:
craft/config/db.php:<?php// ..// The database username to connect with.
'user' => substr(getenv('C9_USER'), 0, 16),// ..// The name of the database to select.
'database' => 'c9',// ...
Run the Craft CMS 3 Installer
Re-run the application and point your browser to your.c9users.io/admin/ and voilà:
After entering a couple of settings, your Craft CMS 3 Beta is up and runing and you can use all your creative power to craft the site you want.
I hope, this tutorial helped you to get Craft CMS 3 Dev Preview runing on your Cloud9 instance. Let me know if you encounter any issues.
What are your expiriences with Craft CMS?
What sites are you running with Craft CMS? How do you solve front-end editing of entities? I’d love to hear what your expiriences are.