Serving multiple sites using single filesystem - Apache

I've had to set up my server to have different sites point to the same file system several times and have always had to run all over the web to find the instructions in various locations, so I thought I'd put it all in one place so at least I have access to the information for next time. Laughing My sites are hosted using MediaTemple's Dedicated Virtual (dv) server, version 4.0.

Step 1: Create Subscription Using Plesk

First thing to do is add a new subscription (i.e. domain) which would, if left alone, simply behave like a normal server.
Create Subscription Using Plesk

Step 2: Create vhost file(s)

Connect via SSH to your server and find the conf directory of the domain you just set up (e.g. www.mynewserver.com). For this example, you can simply type the following command, replacing mynewserver.com with your domain name:

cd /var/www/vhosts/mynewserver.com/conf

Next create the file vhost.conf using the following command:

vi vhost.conf

Once you're in the vi editor, enter the following:

DocumentRoot /var/www/vhosts/servertouse.com/httpdocs
<Directory /var/www/vhosts/servertouse.com/httpdocs >

php_admin_flag engine on
php_admin_flag safe_mode off

php_admin_value open_basedir "/var/www/vhosts/servertouse.com/httpdocs:/tmp"
</Directory>

Obviously replace servertouse.com with the correct domain/path to the file system you want your new server to reference. I added some additional php paramenters as well. If you are going to need SSL be sure to create a vhost_ssl.conf file as well with the same content. The easiest way to create the vhost_ssl file is to do the following sequence:
<esc> :w <enter> :w vhost_ssl.conf <enter> :q <enter>

Step 3: Reconfigure your server

Once you are out of the vi editor, you need to reconfigure your web server to find and use your new vhost files. Then restart your web server:

/usr/local/psa/admin/sbin/httpdmng --reconfigure-domain mynewserver.com
/etc/init.d/httpd stop
/etc/init.d/httpd start

That's it! Your new server should now reference your existing file system.


Contact Sarasota Web Design