InMotion Hosting Support Center

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

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

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

  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.
Continued Education in Course Drupal 7
You are viewing Section 5: 308: Making a duplicate Drupal test site
Section 4: 309: How to find your Drupal 7 database name
Section 6: 310: Setting up a Google analytics module for Drupal 7

Support Center Login

Social Media Login

Social Login Joomla

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
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 


19,033 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."


30,302 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 (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


However on the testsite  - typing does not work. Howwever - I noticed that typing 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


30,302 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 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 and successfully. I also tested and 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-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/

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

how to resolve this?


19,033 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,

n/a Points
2014-08-17 3:01 am

Hi Team,

thank you so much for this tutorial. Everything went great. I followed all instructions step by step.

However, i am facing weird issue. 

lets say my site is and it is running on drupal 6.22

i created a test domain called - test.example.comi export import database, created user in mysql, copied all drupal files including my site files and edited settings.php

i editted .htacess file as per the comments from your team. 

n then when i test my subdomain - it installed drupal but it gave me a clean drupal platform. 

What i was expecting was a clone version of my site but instead i have a blank version of drupal. 

What to do ? Please guide me. 


30,302 Points
2014-08-18 12:00 pm
Hello Dhaval,

I am a little confused by your question. After the file copy and changing the configuration files to point to the new database you should have seen the proper site. Did you say you installed Drupal in the subdomain after you copied the files over?

Kindest Regards,
Scott M
n/a Points
2014-08-18 3:02 pm

Hi Scott, you are absolutely right.

But why i did it is because.. 

after completing all the steps mentioned in your guide, when i visited the subdomain it was loading with blank page and no activity at all (i mean there was no process wheel spinning in google chrome tab etc)

i tried multiple times and apart from subdomain i also tried same process on my localhost using MAMP server (i am on Mac)

i also tried firing but nothing happened so as a last try i tried and something happened (that is the installation). 


Oh this also reminds me of one strange thing -which now when i think- it kind of makes sense. 

While finishing step8 (importing database successfully) i did saw the message of tables imported successfully - However when i clicked on that database it still showed empty database (no tables found). I restarted browser, removed cache etc but it was still showing empty database. 

Please help me or guide me in a right direction. 


30,302 Points
2014-08-18 3:11 pm
Hello Dhaval,

The white screen can often be due to php errors. You will want to check error logs and set up Drupal to report any errors. Below are a couple of pages from the Drupal site to help you with that:
Blank pages
Show errors while developing

The database should have imported correctly, however, if you do not see the database size change and have refreshed your browser, be sure to contact your hosting support as to why.

Kindest Regards,
Scott M
n/a Points
2014-08-18 3:43 pm

Thanks Scott,

I will give that a go and see where this leads me. Thanks me once again. 

n/a Points
2014-09-10 10:29 am

I don't know what changes to make in the .sql document. you say to replace all istances of the old subdomain with the new one. But I don't know what the old subdomain is. I have no idea where my drupal files are installed to. I know the site is in the public_html directory, but im lost beyond this point.

19,033 Points
2014-09-10 11:35 am
Hello Scott,

Thank you for your question. In the .sql document, you need to find all instances of the old domain name, for example:

Then replace that with the new subdomain you created in Step 2 of the first section. For example:

If your site is installed in the public_html directory, then your Drupal files will also be in that folder. For detailed information on the folder structure, see our full guide titled "What directory should I put my files in?"

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

Thank you,
n/a Points
2014-09-10 10:34 pm

another question. So, I copied over the drupal files, but the settings.php file would not upload. I was told I didn't have access. So, instead, I just downloaded drupal and uploaded it to and created the settings.php file as if it were a new install. Of course, now, when I go to, it wants me to install drupal. Now, I'd be happy to install drupal to the test site, provided it won't damage the production site. However, I am concerned because the test sites directory is located in public_html/testsite and the production site is located in public/html. I just want to be sure that there won't be any problems with the production site if I run the install in the test site directory.

30,302 Points
2014-09-11 6:35 am
Hello Scott,

It is fine to install Drupal into a subfolder. Just remember to use that subfolder in the URL and not simply the domain name when installing.

Of course it is always advisable to make a copy of your public_html folder prior to making any changes just in case.

Kindest Regards,
Scott M
n/a Points
2014-11-18 1:19 am

Scott, I followed the instructions (great quality!) and seemed to have created a copy of my site: when I go to the subdomain link it pulls up the exact home page as the original - awesome!

However, none of the links seem to work (menu, subsections, etc) - on attempt, it gives me the following message:

"Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request."

Any quick places I can look to correct this? 

Already made sure the permission were re-set.



11,186 Points
2014-11-18 9:41 am
Typically, this error would be caused by your .htaccess file. Try renaming it to something else or ensuring that it is exactly as it is in the main site. You may need to show hidden files in the cPanel file manager to see it as it is a hidden file. If you continue getting this error, you may need to contact technical support in which they will be able to provide you with the exact reasoning for your specific issues.
n/a Points
2015-07-30 11:44 pm

Hello !


Thank you for this article.

After following it, I can see my home page and access my different articles, but I don't have any css applied, it seems like it doesn't find the theme...

Also, I can't log in, using /?q=user/login I get a blank page...


Any suggestion ? 



5,833 Points
2015-08-01 12:27 pm
Hello Nick,

Can you provide your domain so we may look into the issue further?

Best Regards,
TJ Edens

Post a Comment

Email Address:
Phone Number:

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

23 Questions & Comments

Post a comment

Back to first comment | top

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:
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!