About two weeks ago I had setup Drupal 4.7.4, MySQL 4.1.12, and Apache 2.0.52 on my RedHat Linux AS 4 server to serve my site, timarcher.com.
Now one of my friends would like to setup a site for himself. We wanted to leverage everything that I had already configured for timarcher.com and not have to setup another Drupal code base. The basic requirement was to use the same Drupal installation/code base, but allow my friend to have his own configuration, database, users, etc and allow his site to display entirely different content than my existing site.
The remainder of this post will detail the steps I took to get this to work, and assumes you already have a working Drupal installation.
- Create a new MySQL database to hold the information for this Drupal install. My current Drupal database is named drupal, and since my new site will be for the domain filmoregroup.com, I will name the new database filmoredrupal. You can name the database anything you’d like.
mysqladmin -u root -p create filmoredrupal
- Now grant the MySQL user that your Drupal database is running under access to the new database we created above. In my case, I had to grant the user drupal access to the database filmoredrupal.
mysql -u root –p GRANT ALL PRIVILEGES on filmoredrupal.* to 'drupal'@'localhost' identified by ‘mydrupaluserpw’; flush privileges;
- The last step to setting up the database for the new site is to create the appropriate database objects Drupal needs to run. Change directory to your Drupal installation and then go into the database subdirectory. This directory holds the file we’ll need to load into MySQL. On my server the commands to change directory and create the DB objects were:
cd /var/www/timarcher/database mysql -u drupal -p filmoredrupal < database.4.1.mysql
- Go to the directory holding your drupal website files. On my server this is /var/www/timarcher. Inside your Drupal directory should be another directory named sites. Change into this sites directory:
cd /var/www/timarcher/sites
- This directory should already have a subdirectory named default. We will create a new directory with the name of the new domain that Drupal will serve pages up for, and assign it appropriate permissions. Since the domain name for my friends site will be filmoregroup.com, I create the directory with that name.
mkdir /var/www/timarcher/sites/filmoregroup.com chmod 755 /var/www/timarcher/sites/filmoregroup.com
- Change into the new directory created above, and then copy the default settings for your currently working Drupal site. Remember to replace filmoregroup.com in my examples with your own domain name!
cd /var/www/timarcher/sites/filmoregroup.com/ cp ../default/settings.php ./ chmod 644 settings.php
- Edit the file you just copied named settings.php. We will change the information that tells it what database to connect to. We need to change the line that has the parameter for $db_url. This line should have the username, password, and database name for your existing Drupal install. Change the database name to be the name of your new database created in step 1.
vi /var/www/timarcher/sites/filmoregroup.com/settings.php
The configuration line for me changed from:
$db_url = 'mysql://drupal:mydrupaluserpw@localhost/drupal';
To:
$db_url = 'mysql://drupal:mydrupaluserpw@localhost/filmoredrupal';
- The last step is to setup the virtual host in your apache config file to point to the directory containing your Drupal installation. On my server I edit the /etc/httpd/conf/httpd.conf file and add the following virtual host entry at the bottom:
# Virtual host as1.filmoregroup
#DocumentRoot /var/www/filmoregroup/ DocumentRoot /var/www/timarcher/ ErrorLog logs/filmoregroup_error_log ServerAdmin tima@as1.filmoregroup.com ServerName as1.filmoregroup.com ServerAlias www.filmoregroup.com ServerAlias filmoregroup.com ServerSignature email TransferLog logs/as1.filmoregroup_access_log ErrorLog logs/as1.filmoregroup_error_log - Restart Apache and then open your web browser and navigate to the new domain you setup.
/etc/init.d/httpd restart
The basic setup has now been completed so that your existing Drupal installation will serve pages for your new domain. The new domain has its own database, users, etc and displays entirely different content than your existing site. You may now start configuring this new Drupal configuration just as how you had to do when you first installed Drupal.

del.icio.us
Digg
StumbleUpon