If you have already viewed Part 1 of this guide at http://matc-online.co.uk/2015/03/08/setting-up-moodle-on-c9-io-part-1/ then you should have Moodle code on your server but will not yet have Moodle running. The first thing to do is to press the Run Project button at the top of the Workspace screen which will start the apache server. You can then select the preview button to be shown your server. If everything is working correctly you will end up with a preview window open within your space that should show the default Moodle installation screen. I found that the preview is https:// and does not display correctly so copied the provided URL into my normal browser but with the http:// prefix. Clicking next from the language select screen will ask you to select your paths for the installation. The web address and Moodle directory should be automatically detected but you will need to create a Data directory. This should be outside of the Moodle files structure. The commands I used were.
cd .. mkdir moodle_data cd moodle_data pwd
These commands move you above(outside) the server files and create a new folder called moodle_data. Then move into the folder and pwd will show you the path that you need to enter as the Data directory path in the Moodle installation form. Once the Data directory path is entered click on Next to move to the database selection screen. From here I selected Improved MySQL, I understand PostGreSQL is supported on Cloud9 too. Before we can move on further we need to add MySQL to the applications in our Workspace. This is fairly easy using the instructions at https://docs.c9.io/v1.0/docs/setting-up-mysql & https://docs.c9.io/v1.0/docs/connecting-php-to-mysql The commands I used were
mysql-ctl start mysql-ctl cli
to get into the MySQL terminal
show databases; select @@hostname;
You should have a default database created called c9 and the select command should reveal your hostname. In the Moodle database settings enter the hostname that you have just collected (rather than use locahost) and enter c9 as the database. The username can be root and the password can be left empty. This is definitely not how to set up a real site but will work for a local development environment N.B. you should never ever ever do this on a live site!!! This will take you to the Moodle server checks. Which will fail as you do not have cURL installed which is required, you are also missing xmlrpc and intl which are optional. So wee need to go back to the command line to install and enable cURL support.
sudo apt-get update sudo apt-get install curl libcurl3 libcurl3-dev php5-curl sudo service apache2 restart
This will check for updates, install the curl extension and then restart the apache server. After this you can reload the Moodle server checks page and should pass the cURL check. For my purposes I do not need the xmlrpc and intl extensions but searching Google for adding php extensions in Ubuntu should yield results that show how. If you have passed enough of the server checks you should be able to press Continue and Moodle will start it’s installation. Once complete you can set up your admin account and start playing. You do not have too much free space so can not do a great deal with uploaded files but the server will have node.js on it so you can use LESS and Grunt and all of those tools on the server. Learning about LESS and Grunt is one of the main reasons for setting up this server so hopefully as I learn more I can post it here soon.