How to setup Drupal on Codio in minutes

Microserve's picture
Sep 4th 2015

Installing Drupal on a *local development environment, for the first time, can be a baffling process!
Place this file here, change that setting, connect to some server, something to do with lamp stack etc?

Luckily, with the emergence of cloud based IDEs (integrated development environments) like Cloud 9 and Codio, we can now make this process much simpler, accessible and efficient. For more on Cloud based IDEs, see Martin's post Coding In The Cloud.

In this post I'm going to guide you through a few steps, specific to getting Drupal up and running on Codio in minutes.

*This tutorial assumes that you are comfortable with using a terminal based interface and have a working knowledge of Drupal using the LAMP server stack.

Install Drupal on Codio in minutes

Step 1 - Register with Codio it's FREE!

Before anything else you need to visit codio and sign up to a free account.

Step 2 - Create a project

Once you have a Codio account, visit the dashboard page and choose New Project in the top right corner.

For the available starting point options, choose LAMP.  
This will setup a new Codio 'box' - A unique server instance for use with our project, which contains it's own LAMP stack, a new blank MySQL database and an integrated text/code editor.

Add a name and a description for our project, then select the visibility (private projects are a premium feature in Codio so leave it set to public unless you fancy paying for a subscription). Once you're happy, click create.

Step 3 - Install Server Utilities And Software

Just like Blue Peter, here's a script we made earlier

Update: 2nd Generation boxes no longer use 'Parts' so for things like Drush you will need to use 'sudo apt-get install drush' instead.

To complete your 'stack' you will need to add various add-on utilities 'to get all the bits talking to each other', these include: php5, php5-apache2, php5-pdo-mysql, php5-gd, mysql and composer.
Also before installing Drupal itself, we need to install drush, - an invaluable Drupal developer's shell/utility app which is full of useful commands for interacting with Drupal via the terminal, giving you the ability to install and enable modules/themes/profiles etc, clear site caches and various other tasks. (you can learn more about drush here).

You could install all of these parts manually, but as we are just trying to get to a stage where you can see and use Drupal quickly, I have provided a script below which automate the entire process for us. 

So...  Open the Codio terminal by going to 'Tools > Terminal' in the main menu and paste the following snippet of code and hit enter:

wget -O - | bash

*To understand what processes exactly are being automated, by  the above script, below is a long-hand version of what is happening in the background.

#A bash script is a text file that contains a sequence of commands for a UNIX-based operating system.
#! /bin/bash

#This installs all the parts you need for Drupal to work
parts install php5 php5-apache2 php5-pdo-mysql php5-gd mysql composer

#Installing drush 
composer global require drush/drush:6.*

#Start up the apache server
echo "parts stop apache2 mysql ; parts start apache2 mysql" > ~/
chmod +x ~/

#Create a random database password and grant user permissions to the database
pass=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 10 | head -n 1)
mysql -u root -e"create database codio; create user [email protected] identified by '$pass'; grant usage on *.* to [email protected]; grant all privileges on codio.* to [email protected]"

#Print out the new username and password so a user can view it and use it
echo "user: codio"
echo "pass: $pass"
echo "db: codio"


When the script above has stopped running, look for the database username and password entries in the code. COPY THE PASSWORD! and paste into a text file or similar, we'll need it later.

Step 4 - Download Drupal Core

Close the terminal and reopen it again. - This will refresh our Codio box cache and let it know drush exists.

Let's install Drupal which will be easy with drush.

  1. Still in the terminal, move up a folder to the root of our box by using the following command:

  2. Now in the root we can install Drupal. The following command downloads the latest version of Drupal core and renames the parent folder from 'Drupal' to match our Codio environment's 'workspace' folder. Don't worry, this has no baring on you Drupal site name, it just prevents all our Codio urls being appended with /drupal.

    drush dl drupal --drupal-project-rename=workspace
  3. CD back into our workspace folder (the folder which now contains our Drupal files and the root of our running Codio box):

    cd workspace

Step 5 - Giving Drupal Access To Our Codio Database

Nearly there.

You now have our Drupal files all downloaded and ready to go. The only small bit left to do is update the database file.

  1. In the folder tree on the left of the Codio interface, go to workspace > sites > default.
  2. Make and in-place copy of the file default-settings.php and rename the new copy to settings.php.
  3. Our default folder should now containing both default-settings.php and the new settings.php. We do this so that we always have an unedited copy as back-up, should we mess up our custom copy.
  4. Open the new settings.php file.
  5. We're going to tell Drupal which database to use and which login credentials to use when accessing it. These settings are for our local environment only. When moving our site to a production environment (or to any other environment for that matter) we will need to update to reflect the database which we want the site to access. Here we're on our Codio box, so we're using our 'codio' database.
  6. Copy the code below and paste it in, below line 216.
  7. Replace the password for the one you copied earlier in step 3, then save the file (Ctrl + S). The database name and username will always be 'codio'. It's fine to leave these as they are, as on Codio there is a completely unique LAMP stack per project, therefore no chance of conflicting database names.
$databases['default']['default'] = array(
   'driver' => 'mysql',
   'database' => 'codio',
   'username' => 'codio',
   'password' => 'your_password_here',
   'host' => 'localhost',
   'prefix' => 'main_',
   'collation' => 'utf8_general_ci',

Step 6 - Install Our Drupal Site

Now to tie all the bits together and actually install the Drupal site from the file downloaded earlier. 

  1. From the top Codio menu, click the dropdown next to project index (static) and select box URL
  2. The browser will open a new tab with the new box setup and running.
  3. Notice the unique server alias url in the address bar (Codio will auto-generate one at random so it could be called literally anything).
  4. In the address bar, after the url add 'install.php' - for example
  5. Hit enter.

That's it, now just run through Drupal's normal installation process and you are good to go!


Installing Drupal can now be a (relatively) straight forward process without any faff. Plus the joy of Codio and many other cloud based IDE's is you can access them, wherever you have an Internet connection.

Super Charged Install Option

Its important to understand the steps above, but if you are in a real rush and need Drupal set up on Codio as quickly as possible, I'm also including the below automation script, which will automatically (duh!) take care most of these steps for you, including creating and editing our settings.php:

wget -O - | bash

To use this speedy set-up script do the following:

  1. Create a new Codio project only this time select default rather then LAMP.
  2. Open terminal and run the code above
  3. Skip to Installing our site like in step 6 - 'Install our Drupal Site'

* Foot Note
Although of course technically cloud based IDEs aren't 'local' to your specific machine (a possible advantage actually, as you can access them from any machine with an internet connection and the correct login), but here were are using Codio as 'local' development environment as opposed to a live production server.

Ashley George's picture

You may also like...

Git Basic Principles & Concepts (for new developers)

Ashley George, Aug 14th 2015
As a new developer, learning all the Git commands and theories is pretty intimidating along with all of the other new knowledge. So I wrote the following guide, which is the document I would've like to have been given when I started.



Sep 10th 2015 - 1:09pmreply
NikLP's picture

FYI I've got a similar guide (without script) that I wrote a while back using the very nice Koding service which is similar. Here it is:

Bob Lucore

Sep 10th 2015 - 3:09pmreply
Bob Lucore's picture

Can you explain in more detail what "free" means on Codio? When I look at their pricing link I don't actually see a free option. But on the other hand, it did set up an account for me without asking for a credit card.


Sep 10th 2015 - 4:09pmreply
Erik's picture

The link to Martin's post Coding in the Cloud is broken (not a relative path?)

Rick Donohoe

Sep 15th 2015 - 2:09pmreply
Rick Donohoe's picture

Thanks for spotting that Erik, I've fixed that now.

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.

Related Blogs

Sophie Shanahan-Kluth's picture
Mark Pavlitski's picture
Rick Donohoe's picture