Duplicate a Drupal Installation

Posted in |

We want to duplicate an existing Drupal installation for testing purposes. In this case the duplicate will reside on the same Fedora 8 server.

Our original live domain is www.example.com.
Our duplicate domain will be dev.example.com.

Duplicate the MYSQL Database

Our initial database is named drupal_live

Dump out the database as sql.

cd ~
mysqldump -u root -pPASSWORD drupal_live > drupal_live.sql

In phpMyAdmin create database drupal_dev. We can either grant all privileges to our new database to a user of the old database or generate a new user specifically and grant them the required privileges.

Then import the dump into the new database.

mysql -u root -pPASSWORD drupal_dev < drupal_live.sql 

Duplicate the Drupal Installation Files

Duplicate the Drupal code base in /var/www/html/drupal.

cd /var/www/html
cp -a drupal drupal-dev


Using the archive option ensures that essential hidden htaccess files get copied correctly.

If we copy the installation up out of html to ../html then the site will probably fail as the Apache AllowOverride directive usually targets /var/www/html. In such cases the htaccess file will not be accessed and the URL rewriting required for clean URL operation will not occur.

Edit Site Settings

In the Drupal sites folder rename www.example.com to dev.example.com.
If the site was specified by domain only then the above will not be required.

Edit the settings.php to point to our duplicated database.

$db_url = 'mysqli://user:password@localhost/drupal_dev'; 

DNS Settings

Update our DNS zone so that the A record for dev.example.com points to our server.

Configure Apache

Edit /etc/httpd/conf/httpd.conf and create new virtual host entry for dev.example.com.

<VirtualHost *:80>
    ServerAdmin admin@example.com
    DocumentRoot /var/www/html/drupal-dev
    ServerName dev.example.com
    ErrorLog logs/dev.example.com-error_log
    CustomLog logs/dev.example.com-access_log common
 </VirtualHost>

Submitted by Jonathan Mitchell on Sun, 04/04/2010 - 19:08

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
Let us know you are human.
14 + 2 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.