Hosting Tutorial & Guide

How to Create a Drupal Test Site for Local Experimental Testing?

updated on May 07, 2015
How to Create a Drupal Test Site for Local Experimental Testing? It's a great way to make a duplicate Drupal site for testing or development purposes, and our tutorial is intended to outline the detailed steps to create a Drupal test website so that you can make any experimental changes without affecting the live site. Generally speaking, the whole copy process consists of four main steps. Now, let's get right to the point.

How to Create a Drupal Test Site?

As Drupal itself and the modules keep changing at a frequent rate, it is highly recommended to make all changes or settings to a test site. To achieve this objective, you can use the following instructions as a reference.

Step 1 – Create a New Subdomain
To separate the existing website from the future test one, you should firstly create a subdomain via the control panel offered by your hosting provider. For the sake of convenience and clarity, we prefer to take the example of the easy-to-operate cPanel control panel here. As usual, the first thing you must do is to log onto your cPanel account. Here is what the admin interface looks like.

Drupal Test Site - Enter cPanel Interface

From here, just scroll down to the "Domains" section and make a click on the "Subdomains" icon as follows. This will open configuration page where you will be prompted to enter your preferred subdomain name for the testing site in the following text box. Inside the next drop-down list, it is also possible to make a selection the domain that you want to create it under. By the way, there is an option for you to specify the "Document Root" for the newly-added subdomain.

Drupal Test Site - Create a New Subdomain

Even if you leave the above "Root" section blank, a sub-folder for this subdomain will also be created within the home "public_html" folder automatically. After done with all settings, do not forget to click this "Create" button to store your changes. If nothing goes wrong, there will be a success message expressing that your subdomain has been created.

Step 2 – Set Up Another Separate Database
As Drupal always stores the website files and content in one database, you also need to import the database to another separate database. To do this, just revert back to the main menu of cPanel and select out this "MySQL Database Wizard" option under the "Databases" column.

Drupal Test Site - Find MySQL Database Wizard

Upon entering this "MySQL Database Wizard" page, it will prompt you to input the new database name in the "New Database" blank box. Pay attention that, the filled-in database name can only include alphanumeric characters. To proceed, just press the "Next Step" button there.

Drupal Test Site - Create New Database Name

The next step is to create your database users by creating a username that include more than seven characters. Taking the data safety into consideration, you'd better make the password as strong as possible. If you have difficulty in thinking out a secure password, you can click on the "Password Generator" button to generate a random password of the specified length.

Drupal Test Site - Create Database Users

Make sure that you would re-enter the filled-in password before clicking the "Create User" option. As those mentioned database name, username and password will be used in the later setup, you'd better save them in a local text or notepad document.

Drupal Test Site - Add Privileges to Database

The last step is to add a user to your new database. As is displayed, you are required to assign privileges for visitors to access the database. Simply check the box next to "All Privileges" to select all provided options and then press the "Next Step" button to end this database creation process.

Step 3 – Export the Current Database
To make a backup file of the existing database, you will have to export its included files. To perform this task, you would need a powerful MySQL database management tool called phpMyAdmin that is available from the same "Databases" section.

Drupal Test Site - Enter phpMyAdmin Section

In the next screenshot, just choose the database you're using from the left-hand menu. If done, just click on the "Export" button at the top toolbar to continue. Inside the "Export" heading, check the radio button next to the "Custom" export method and you will be presented all potential options as below. Make sure that all of the related tables would be selected out there.

Drupal Test Site - Choose Your Export Method

Within this "Output" section, click the "Save output to a file" button. Note that, the file name template and the file character can also be edited and styled to your liking. If your database is pretty large, select either "gzipped" or "zipped" option to compress the ready-to-download file. The default "None" option will save the database files without compression. Be sure that this "SQL" option would be selected from the "Format" drop-down list.

Drupal Test Site - Output Format Options

By the way, there are more format-specific and object creation options at the bottom of this page. Just leave those advanced options to defaults if you don't know what they really mean. Do not forget to press the "Go" button to start copying your database. Note that, this will prompt you to verify the "File Name" and "Save Type" as below. Try storing the database files on the desktop or somewhere you can remember.

Drupal Test Site - Store Database Files Locally

Important to Note: Now that you've got a copy file of the database locally, it's time to open the downloaded .sql file via a text editor like Notepad++. Just search and change all of the instances of your old subdomain into the new subdomain. Assuming that your current Drupal is hosted on drupal.yourwebsite.net, you should adjust all instances of this subdomain into the new one like drupaltest.yourwebsite.net.

Step 4 – Import the Database Files & Folders
Last but not the least, you still need to move the downloaded database files and edit the settings.php file so as to put the new database into use. Here, find and enter the "File Manager" from this "Files" area.

Drupal Test Site - Enter File Manager Section

And next, enter the current Drupal install directory and copy the included files to the new document root directory. Pay attention that, this root directory is always the same name as the newly-created subdomain. Do not select the files that are irrelevant to your Drupal site. Even if you select some unrelated files or folders, you can hold the "Ctrl" key and right-click on them to deselect. Once you have done, just click this "Copy" button lying at the upper-right toolbar of the "File Manager" page.

Drupal Test Site - Click Copy Button

Within the pop-up window dialogue, just enter the destination folder (this should be your subdomain document root location) in the "Copy file to" box. Press the "Copy File(s)" button to continue.

Drupal Test Site - Enter Destination Folder

In the meantime, you will have to update the database settings by going to the root directory for the new domain name. Simply open and edit your settings.php file normally located at /public_html/YourTestSiteName/sites/default/settings.php. To perform your testing task, you need to update the username, database name and password to the new database credentials. After the completion of all changes, remember to click the top "Save Changes" button. Congratulations, you've set up a Drupal test site now!

Drupal Test Site - Find Your Settings File