Website Deployment

Deployment is the process of moving a website from a Local Environment to a Live Server.

Version Control

Typically in Website Development, there are 3 versions of a site; Development, Production/Test and Live.

The Development version is the first version of the site, usually stored on a local server. This is usually building the site to a Minimum Viable Product, where the site is setup and configured to a standard where the site can be used but not all pages, features and content has been added yet. Dummy Text and Images are typically used throughout this version as placeholders.

The Production/Test version is typically where real content and images are added to the site. This version is created when the Development phase has been completed and is typically stored on a global server as sometimes the client may require access to build up the pages and add content. This is also where the site testing takes place before the site is deployed to Live.

The Live version is the completed version of the site which is stored on the clients Global Server with their chosen domain. If any changes are required of the site, they are typically completed on a previous version before being pushed to Live. Once the site is Live, Developers may continue Maintenance phases of the site, where bugs and fixes are addressed.

Version_Control

How to Deploy a Drupal Site

Assuming you already have new hosting for your site, there are quite a few ways a site can be deployed to this host, one of these ways is the SFTP method. I use the Filezilla FTP Client for this, which is free for Windows and Mac. Once you have Filezilla installed, open the application, click File and select Site Manager. On the window that appears, select ‘New Site’. Here you will be asked to enter the Host, Port, Username and Password. Once these have been filled in, click ‘Connect’ which should connect you to your server and display your site’s Files and Folders – if your connection details were correct.

Now you are connected to your Server via Filezilla, we need to open the folder where your Drupal site is installed, this is typically called htdocs or public_html. We will now need to save a copy of your site locally on your machine. You could create a folder on your desktop for this called ‘site_backup’. Highlight all files and folders in your htdocs or public_html folder and drag them into the folder you just created. You should now see lots of writing appearing at the top of your Filezilla window while your files are being copied over. Once the writing has stopped scrolling and you see a message saying something like ‘File Transfer Successful’ this is complete.

You will now need to back up your Database – we will use phpMyAdmin for this. If you are unsure how to access phpMyAdmin for your site, you may need to contact your hosting company. Once you are in, look for your Drupal Database on the left hand side, it should have the word ‘Drupal’ or something similar in it. Once you have selected your Database, click Export on the top toolbar. On the page that loads, select ‘Custom’ under Export Method. Next select ‘Zipped’ for the compression option and then scroll down and click ‘Go’. You should now save this file somewhere on your desktop, next to your site_backup folder from the previous step. Your site has now been saved locally!

Next you will need to open your new hosting site (I use CPanel for this) and login. Once logged in, you will need to create a Database for your site. In CPanel, there is a MySQL Database Wizard. Here you are asked to create a Database, Name it, create a Username and Password and finally grant any permissions. Once completed you should now see your Database Name prefixed with your Cpanel username and an underscore (CPanelUsername_DatabaseName) – you should take a note of this.

We will now need to add your Database from your old site. To do this in Cpanel select phpMyAdmin and select your new Database from the left. Click Import and select the Database we previously downloaded. Your Database should now be imported. We now need to edit our settings.php file. To do this, open the site_backup folder which you saved locally earlier, look for Sites > Default > Settings.php. In this file, somewhere around line 208, you should see the following:

'database' => 'Your old database',
'username' => 'Your old username',
'password' => 'Your old password',
'host' => 'localhost',

This information should be changed to your new Database, Username, Password and Local Host. Once you have done this remember to save the file back into the site_backup folder. The final step is to upload your site files which again can be done in Filezilla, or if using Cpanel – by using their File Manager. If using Filezilla, click File > Site Manager and enter your Host, Username and Password (and port if required). Look for public_html or htdocs and open it. You can now drag all contents from the site_backup folder which we stored locally to your desktop earlier, into here.

That’s it! You have now Deployed your site successfully!