When administering a Drupal site, its a good idea to make a duplicate site for testing purposes. This allows the administrator to make large changes to the web site while the existing site is still running. This article will teach how to make a duplicate Drupal site for testing.

Steps to make a duplicate Drupal site on a subdomain

First step is to create the subdomain

To set up a Drupal test site, create a subdomain that you will use to separate your Drupal site. The following are the steps on how to set up the subdomain.

  1. Log into your cPanel
  2. Create the subdomain that will be used for the Drupal testing site, for example you may want to name it something like testsite.yourdomain.com.

Second, set up the Database

Because Drupal stores all the content in a database, the database will need to be imported into a separate database. The following section will explain how to export your Drupal database, change the site url in the database, and import the database into your testing database.

  1. Create drupal databaseCreate a database.
  2. Create Drupal database userCreate a database user.
  3. Assign permissions to Drupal database userAdd the user to the database will full permissions.

    Important! Make sure you save the Database name, Username, and password in a notepad or text document. These will need to be used later in the setup.

  4. Export the old Drupal DatabaseIn PhpMyAdmin, export your current database
  5. Make a duplicate of your Database on your local computer. (This is to prevent you from having to export the database again due to any possible mistake.)
  6. Find and replace old domain with newOpen the .sql file with Notepad++ or another editor.
  7. All occurances replacedFind and replace all instances of the old subdomain with the new subdomain. For Example, if your existing Drupal is on drupal.yourwebsite.org

    Replace all instances of the old domain with the new domain. For example: drupaltest.yourwebsite.org

  8. Import the Drupal database to the new databaseImport your Database into the new database you created.

Finally, move the Drupal files

Now that the database is set up, the files will need to be moved and the settings.php file will need to be edited to use the new database connection. The following section will explain how to move and set the settings.php file to work on the new subdomain.

  1. Go to your File Manager.
  2. Copy your Drupal Files from your current directory to the document root directory created for your subdomain. The root directory usually is the same name as the subdomain that was created.
  3. Select all the Drupal files.

    Important! When selecting all your Drupal Files, make sure any other files and/or folders not related to Drupal are not selected. After selecting all, hold the Ctrl key and click the folders to deselect any "non-Drupal" files and /or folders. If you do not deselect unrelated files and/or folders, there will be duplicates taking up disk space.

  4. Click Copy at the top right side of the File Manager.

    Type the path to the folder you want to move your files to. (This will be the subdomain document root location) Click Copy.

  5. Now we will need to update the database settings for Drupal. Navigate to the path to the Document Root folder for the Sub Domain. For example: /home/userna5/public_html/testdrupal/sites/default/settings.php

  6. Select the file and click the code editor.

  7. Update the Drupal settigns.phpUpdate the database name, username and the password for the database to the new database credentials so you can test them.
  8. Click on the Save Changes button.
Did you find this article helpful?

We value your feedback!

Why was this article not helpful? (Check all that apply)
The article is too difficult or too technical to follow.
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
How did you find this article?
Please tell us how we can improve this article:
Email Address

new! - Enter your name and email address above and we will post your feedback in the comments on this page!

Like this Article?


Post a comment
n/a Points
2014-03-17 9:12 am

Hi, JamesThanks for your article, however, in the step 4 of the final part, I couldn't copy files to my testsite's default folder, then I tried to use the upload function, and it still doesn't work.

Can you help me solving this problem? 

ThanksBy Chiheng from Taiwan 


7,266 Points
2014-03-17 9:19 am
Hello Chiheng,

Thank you for your question. We are happy to help, but need a little more information.

Are you selecting the files (step 3) before clicking the Copy button?

Do you see any errors? What are the errors?

What type and version of Browser are you using?

Have you tried another browser?

If you have any further questions, feel free to post them below.
Thank you,

n/a Points
2014-05-23 10:16 am

Hi John Paul,

Thank you for the instructions. I am having trouble getting mine to work. I am getting a message "error 403 - You don't have permission to access the requested resource. Please contact the web site owner for further assistance."I am pretty sure that it's not a propogation issue, because I created another subdomain just now, in which I placed a simple index.php, and it works fine.I followed your instructions very carefully and the only place where i think error might have cropped up is:


Settting up database:Step 4: my phpMyAdmin  is a different version than  the one in the picture of the instruction link, and I had some trouble navigating it, and am not sure if I did it correctly:


Moving files: Step 3: I have a lot of files in the "to be copied from"  directory and not all are drupal related. So I am not sure if I have copied all the drupal files or if I am missing some - should I just copy all?

Any help you can provide would be greatly appreciated.


n/a Points
2014-05-23 10:59 am

Hi John Paul,

After sending my previous email, I tried copying all the files to my new "testsite" folder (just in case I inadvertently missed a drupal related one).

Now the testsite is partly working  - and it replicates the front page of the original site perfectly - but it only shows the front page only. When I try to login or go to nested pages, I get:

"Error 500 - Internal Server Error -  An error was encountered while processing your request. Typically this is a temporary condition. Please contact the web site owner for further assistance."


15,308 Points
2014-05-23 11:25 am
Hello Bruce,

You still needed to copy the .htaccess file from the main to the subdirectory as well. Once copied, the RewriteBase needed to be changed to accommodate the new subfolder. I made that change for you and the login area is now appearing.

Also, since the site is not using the base domain name, we needed to change the $base_url variable to reflect your domain and then the subfolder in the sites/default/settings.php file.

Please let us know if you have any further issues.

Kindest Regards,
Scott M
n/a Points
2014-05-23 12:43 pm

Hi Scott.

Thank you very much - it seems to be all working now. A couple of additional questions:

1) Strangely I could not (and still can't) see the htaccess files even though I had enabled "see hidden files" when I open file manager.

2)Also - I am confused by the hierarcy of the urls. The url to the front page of the testsite is www.testsite.myprimarydomain.com (you'll note that since this is a public comment I've written "myprimarydomain" instead of my actual domain).

So I expected that in the testsite to see additional content other than my home page, I would have to input the url in the same method as my live website, but that does not work.

For instance, on my live website, to see the page called "reincarnation" - I type www.myprimarydomain.com/reincarnation


However on the testsite  - typing www.testsite.myprimarydomain.com/reincarnation does not work. Howwever - I noticed that typing www.myprimarydomain.com/testsite/reincarnation does work!


That surprised me. Is this normal? (I don't want to have problems when I end up finishing my work on the test site and replacing my original site).


Thank you


15,308 Points
2014-05-23 2:58 pm
Hello Bruce,

I'm happy to assist with your additional questions.

1) the .htaccess file should be the first file after the folders if your file list is being viewed alphabetically. The . will register before letters so it will show before files that begin with a. I do see it there in the testsite subfolder, however.

2) With my original fix, (I didn't take into account using a subdomain.domain.com format) the changes I made caused the errors you now see when using the subdomain format. I have since altered it to display both ways, oddly enough by simply reversing the original changes.

I have tested testsite.domain.com and domain.com/testsite successfully. I also tested testsite.domain.com/reincarnation and domain.com/testsite/reincarnation successfully. Both formats also grant access to the login page without error. I assume the other pages should also work.

I wish I could tell you what the difference was between when you first contacted us and now, but there is no difference in the .htaccess file and settings.php file between then and now. Why it is working now is a complete mystery to me.

Please let us know if you have any further questions, I'm happy to assist.

Kindest Regards,
n/a Points
2014-05-23 3:57 pm

Thanks Scott

n/a Points
2014-07-18 1:28 pm

Hi friend, good and easy tutorial, i did everything what you said, but when i finished the process the site has a problem with views, it shows this

Notice: unserialize(): Error at offset 4195 of 5857 bytes en views_db_object->load_row() (línea 2251 de /home/domain/public_html/test_site_folder/modules/views/includes/view.inc).

all site works fine, only Views give me errors that appear in views pages and views block.

how to resolve this?


7,266 Points
2014-07-18 2:25 pm
Hello Rolando,

Thank you for your question. I saw a similar problem posted in the Official Drupal forums, where they offer possible solutions.

Since this error seems related the 3rd party Drupal module Views, I recommend confirming it is setup correctly, and compatible with the version of Drupal you are running.

If you have any further questions, feel free to post them below.
Thank you,


Post a Comment

Email Address:
Phone Number:

Please note: Your name and comment will be displayed, but we will not show your email address.

News / Announcements

WordPress wp-login.php brute force attack
Updated 2014-07-17 06:43 pm EST
Hits: 201654

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Need more Help?


Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!