How to copy site to another directory
System: Apache + PHP + MySQL + Linux
I had my site at, say, example.com and wanted to set up beta.example.com as a duplicate site to test some ideas. This meant duplicating the database and code to a separate database and code tree. That way I could modify beta.example.com without harming example.com.
In my case I'm on a virtual-private-server (same thing as a dedicated server) and have full control over the system. If you're on a shared hosting account the steps will be different. Unfortunately the details of how share hosting accounts are setup vary so widely, I'm not going to try and generalize the instructions for that.
- In the DNS, create the beta.example.com subdomain. Remember it can take a little while for the DNS entries to propogate properly.
- Duplicate the database tables ... I'm on Mac OS X and used the navicat program to do so, but you should be able to use mysqldump or other similar programs. That is, create a new database and copy the tables and data from the example.com database to the one for beta.example.com.
- Make a directory for the docroot of beta.example.com, and copy the files as so:
(cd example.com/ROOT; tar cf - .) | (cd beta.example.com/ROOT; tar xvf -)
If you only have FTP access this is a little harder. First FTP the files to your local computer, then FTP those files into the new docroot directory. You can also edit the files on your local computer, and then re-FTP them whenever you change something.
- Config apache's httpd.conf for a second VirtualHost with beta.example.com in it. Make sure the VirtualHost entry for beta.example.com preceeds the one for example.com. Make sure the docroot for beta.example.com is a different directory.
- Edit sites/default/settings.php and change base_url and the database URL.
$base_url = 'beta.example.com'; $db_url = 'mysql://username:password@localhost/new-database';
- It's also helpful to override the site name so that the heading on the site glaringly reminds you that you're on the BETA site:
$conf = array('site_name' => 'BETA this sites name');