1

Requirements :
Root shell (ssh) access ( See here  )
Experience using shell based text editors (not covered) or moving files with the shell (not covered)
Preconfigured domains for hosting within your Hosting Control Panel (See Here)
One domain (your "parent" domain) must have Magento installed (See Here)

Step 1 : Configuring Magento

You can use this  guide for an explanation of how multiple stores work and can be configured within the Magento admin panel.  You should create your multiple websites/stores first here as you will need these settings when you are configuring the passthrough index.php in your webspace.

Step 2 : Configuring Plesk

To enable a multistore setup within Plesk you specifically need to relax OpenBaseDir restrictions to allow different domains on the server to talk to each other.  This can only be done by the use of custom configuration files within your Plesk domain configuration, and you can only write custom configuration files as root.

Once you have become the root user you should navigate to the following directory of your first "child" store :

cd /var/www/vhosts/CHILD_DOMAIN_NAME/conf

If you check the contents of this directory you will find a file named httpd.include, this is the configuration file for the domain and should not be touched as Plesk will frequently rebuild and rewrite this file.

We are going to create two files, both with identical content, the first file covers http requests, the second https (encrypted) requests.

The first file to be created is vhost.conf, and to create it using vim you would type :

vim /var/www/vhosts/CHILD_DOMAIN_NAME/conf/vhost.conf

The following data (adjusted for your particular configuration) should be inserted into the text editor (To start typing in Vim simply press "a", then everything you type will pushed to the screen).  You should type this data manually rather than pasting as all lines and line breaks should remain intact, and this will not happen if the data is pasted.  Please note that there are only three lines.

<Directory /var/www/vhosts/CHILD_DOMAIN_NAME/httpdocs>
php_admin_value open_basedir "/var/www/vhosts/CHILD_DOMAIN_NAME/httpdocs:/var/www/vhosts/PARENT_DOMAIN_NAME/httpdocs:/tmp"
</Directory>

Once you have entered this data you can save and exit from Vim with the following command sequence : ESC : w q RETURN (Escape Key, Colon, w, q and then return)

You should then repeat the above process for the SSL configuration file :

vim /var/www/vhosts/CHILD_DOMAIN_NAME/conf/vhost_ssl.conf

After the two files have been created its necessary to alert Plesk to the presence of these files, you can do this by running the following command :

/usr/local/psa/admin/bin/websrvmng -a -v

If you receive any error after running this command you should delete the two files created, then rerun the command.  If you still receive errors you should contact support immediately as its possible that your web server will no longer be running

Assuming you received no errors you should continue.

Step 3 : Adding a passthrough index.php to the child domain

The following file (index.php) needs to be reconfigured to your needs and added to the web root of the child domain :


$mageFilename = '/var/www/vhosts/PARENT_DOMAIN/httpdocs/app/Mage.php';

if (!file_exists($mageFilename)) {
    if (is_dir('downloader')) {
        header("Location: downloader");
    } else {
        echo $mageFilename." was not found";
    }
    exit;
}

require_once $mageFilename;

umask(0);
Mage::run('STORE/WEBSITE_CODE', 'TYPE');

This file can be edited in your usual editor and uploaded to the web root, created via the Plesk File Manager or you can even create it using Vim!

You should now be able to navigate to the child domain and view the appropriate Magento storefront that was configured on the parent domain.

2

Paul,

Thanks for guide, just not sure how to run the command to alert plesk about the new files, i dont seem to have root access via SSH and im not familiar enough with plesk to know any other way to run the command.

Im assuming that the vhost_ssl file is exactly the same as before only with httpdocs substituted for httpsdocs. Also i have set up the parent domain however i haven't udated the nameservers yet so its only accessible by using the IP address and not the domain name, am i right in assuming i can substitute PARENT_DOMAIN_NAME for the ip address?

Thanks in advance.

3

Hi Fantasticals,

1)You become root by giving yourself shell access as the FTP user (HCP ->
Home/Domains -> domain_name -> Setup -> Shell Access -> OK).  Log in as the ftp user through ssh (ie Putty) and then run the following command :

su -

You will be prompted for the root password.  Entering the root password and pressing Return will result in you being escalated to root privileges.  You are now the root user which you can confirm by using this command which returns your user identity :

whoami

2)The two files are identical, Magento (and almost everything else) uses
one directory for secure and insecure content (httpdocs) via a setting
within the Setup page I mentioned above (Use a single directory for housing
SSL and non-SSL content).


3)Ideally you should create the domain with the correct domain name
within Plesk then use the IP to access it (or use your hosts file), the
PARENT_DOMAIN_NAME in the configuration files is the directory name, which
Plesk builds automatically from the domain name, if you change the domain
name then this directory name will change and all your configuration files
will be wrong.

Hope this helps, Ewan

4

Hi,

We now have our multistore setup functioning fine on a vps, but we have a tiny issue and im wondering whether it can be resolved.

We cant provide separate robots.txt files for the child domains as there always going to pick up the file for the parent domain, any ideas?

5

Hi Mr Fantasticals,

There are two options I can see, the first probably won't cut it for you, but I provide it for your benefit :

1) There is a free Magento extension Yoast MetaRobots that tries to significantly enhance robots.txt functionality in Magento.  I've taken a quick look at it and it doesn't mention per store robots.txt but it does seem to offer per page robots.txt functionality.  You can find it hereStandard Nublue advice applies here, back up your site before installing or removing any Magento extensions

2) Alternatively you can use mod_rewrite to redirect each domain to different customised robots.txt files by modifying the mod_rewrite section of your root .htaccess to include lines such as the following (untested) :

RewriteCond %{HTTP_HOST} first.store.domain.com
RewriteRule robots\.txt first.robots.txt [L]

My rewrite coding skills are not the best and I'd recommend testing this extensively in a development environment, but once you have the right code it should work fine (until you upgrade Magento and it overwrites your .htaccess!)

Paul.

6

I've had a little play just now and proved out the workings / code for getting this done.

First my test setup is to display different robots.txt depending on whether you hit the www or the non-www URLs of pagrant.co.uk

So I have two obviously labelled files in my web root :

www_robots.txt
non_robots.txt

And in my .htaccess I have :

RewriteEngine On
RewriteCond %{HTTP_HOST} ^pagrant\.co\.uk$
RewriteRule robots\.txt non_robots.txt [L]
RewriteCond %{HTTP_HOST} ^www\.pagrant\.co\.uk$
RewriteRule robots\.txt www_robots.txt [L]

If you're using this within a Magento setup I would recommend inserting your equivalent of the last 4 lines immediately after the "RewriteEngine On" line.  Magento itself uses rewrites and you will want these rules to be effected before Magento's internal rules.

If you now try www.pagrant.co.uk/robots.txt and pagrant.co.uk/robots.txt it should display a different file (message) for each.

7

Hi guys,
Thanks for this guide.
I've followed the steps and all seems fine, no errors returned, but now when I go to the child domain in a browser it just downloads a copy of index.php.
Would that be because I have something wrong in index.php, or is it likely to be some other cause?
Thanks

8

Hi Chris,

If you go to the child domain in Plesk and ensure php is enabled for it, I think that will fix the issue. You can go this by going to the following in Plesk:

Domains > yourdomain.com > Setup

Hope that helps. Please let me know if that fixes it.

Tom