Hey All,
I recently moved a drupal sub-site from dev machine to production. The base url for my site on the dev machine was something like http://example.com/sub1 and the base url on production had to be http://www.sample.net. These were the steps that I followed:
1. Create a sql dump of the drupal database by using the following command on a linux terminal:
mysqldump -h localhost -u [MySQL user, e.g. root] -p[database password] -c [name of the database] > sqldump.sql
2. Next thing would be to create a tar file of the folder corresponding to the sub-site under the sites folder. For example, I created a tar file of the folder located at /sites/example.com.sub1 by using the command below
tar -pczf sub1.tar.gz /sites/example.come.sub1
3.Make sure all the drupal modules that the sub-site on the dev machine uses are also available on the production machine. Note that drupal modules are stored as a part of the File System and not stored on the drupal database.
4. If you created a custom theme on the dev machine, transfer the folder corresponding to that theme to the production machine as well. You can either use a FTP client software such as FileZilla or SSH Secure to do so. Some people feel comfortable creating a tar file of the custom theme and transferring the tar file to the production machine and later uncompressing the tar file at the destination location. Either ways it works.
5. Transfer the sql dump and the tar file that we created in Step 1 and 2 to the production machine.
6. Unzip the tar file inside the sites folder. Rename the folder to match the domain name. In my case I named the folder to sample.net
7. Create a database using the sql dump. Rename the database if you wish to. If you choose to rename the database, make sure that you change the $db_url variable within the sites/sample.net/settings.php file.
8. Make corresponding changes to the server's vhost file to resolve the new domain. Note that you can add this vhost entry even before transferring the files.
9. Open a browser and type the url www.sample.net. If you did everything right, it should bring up the drupal site mirroring the site that you created on the dev machine.
10. Check the File System of the sample.net site. Go to Administer ->Site Configuration-> File System. Make sure the file system is changed to the one on production machine. In my case it had to be sites/sample.net/files rather than sites/example.net.sub1/files. Note that since we used the same database from the dev machine, few of the settings could have dev machine's settings.
Issue:
One major issue that I faced was, while adding content to the site on the dev machine, users had hardcoded few of the links to the files. For example, to insert an image, the link was /sub1/files/images/image1.jpg . The contents when they were transferred to the production machine, were just the same. I used an UPDATE query on the database in the production machine to UPDATE those hardcoded links. All that the query had to do was to identify /sub1 and replace it with an empty string. Node_revisions is the table where drupal stores the content body and teasers. Hence the query below solved the issue
update node_revisions set teaser=replace(teaser, "/sub1",""),body=replace(body, "/sub1","");
Note: Using an UPDATE query is not always the best approach, but it worked for me. If there is any other solution to solving this links issue, let me know..
Hope that helps..!