I'm trying to run multi-store environment (2 websites) on single Magento instance but I can't figure it out. Looking around the net for solutions, I tried everything but it doesn't work.

The main website works fine but on the second one, I got this warning:

/var/www/vhosts/mydomain2.com/httpdocs/app/Mage.php was not found

I have Plesk + NGINX + PHP-FPM

I tried to setup multiple IP in one network card like this tutorial:

But with no success.

I always got this message:

/var/www/vhosts/mydomain2.com/httpdocs/app/Mage.php was not found

Your assistance is greatly appreciated.

  • It looks to me that you are doing it wrong through Plesk. Magento will handle the multiple sites, you need to tell Plesk to listen to the same IP for multiple domains.
    – SR_Magento
    Mar 4, 2015 at 21:55
  • Are you having problems getting your domain to point to the correct folder or are you having problems getting both domains to work? Mar 5, 2015 at 23:08

3 Answers 3


at http{ } block:

map $request_uri $MAGE_RUN_CODE {
    default   en;
    ~^/fi/     fi;

map $request_uri $MAGE_RUN_TYPE {
    default   store;
    ~^/fi/     store;

at php${ } block:

fastcgi_param   MAGE_RUN_CODE $MAGE_RUN_CODE;
fastcgi_param   MAGE_RUN_TYPE $MAGE_RUN_TYPE;
  • Which file i need to update above lines, nginx.conf.sample or etc/nginx/conf.d/magento.conf? @MagenX
    – zus
    Jun 30, 2020 at 12:40

Here is an example of your conf file that will work with more than one store

map $http_host $magecode {
       .domain1.com default;
       .domain2.com domain2_com;

server {

    listen 80 default;
## SSL directives might go here
    server_name www.domain1.com;
    root   /var/www/domain1.com/current;

    if ($host !~* ^www\.) {
return 301 $scheme://www.$host$1;}

    location / {
        index index.html index.php; ## Allow a static html file to be shown first
        try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler
        expires 30d; ## Assume all files are cachable

    ## These locations would be hidden by .htaccess normally
    location ^~ /app/                { deny all; }
    location ^~ /includes/           { deny all; }
    location ^~ /lib/                { deny all; }
    location ^~ /media/downloadable/ { deny all; }
    location ^~ /pkginfo/            { deny all; }
    location ^~ /errors/config.xml   { deny all; }
    location ^~ /var/                { deny all; }

    location /var/export/ { ## Allow admins only to view export folder
        auth_basic           "Restricted"; ## Message shown in login window
        auth_basic_user_file htpasswd; ## See /etc/nginx/htpassword
        autoindex            on;

    location  /\. { ## Disable .htaccess and other hidden files
        return 404;

    location @handler { ## Magento uses a common front handler
        rewrite / /index.php;

    location ~ \.php/ { ## Forward paths like /js/index.php/x.js to relevant handler
        rewrite ^(.*\.php)/ $1 last;

    location ~ \.php$ { ## Execute PHP scripts
      try_files $uri $uri/ =404;
        expires        off; ## Do not cache dynamic content
        fastcgi_param  HTTPS $fastcgi_https;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_param  MAGE_IS_DEVELOPER_MODE 1;  
        fastcgi_param  MAGE_RUN_CODE $magecode; ## Store code is defined in administration > Configuration > Manage Stores
        fastcgi_param  MAGE_RUN_TYPE website; # or store?
        include        fastcgi_params; ## See /etc/nginx/fastcgi_params
  • Nice! I definitely prefer mapping over host switch! Dec 28, 2015 at 21:24
  • After configuring things and when i reload or restart nginx it throws error ------ nginx: [emerg] "map" directive is not allowed here in /home/html/nginx.conf.sampl Aug 11, 2016 at 13:41
  • @YogeshTrivedi Where are you inserting the map block? It should be inside the http block. Jun 1, 2017 at 19:05
  • 1
    Note. if you run your admin on a separate domain then MAGE_RUN_TYPE needs to be set to store
    – ben.incani
    Sep 14, 2018 at 1:51

To make this work, you should create a domain pointer in Plesk.

First make sure that the DNS settings of both domains point to the Plesk server, so all traffic for both domains will be routed to the same server.

Then create a domain pointer. The domain pointer should make the second domain point to the first domain (assuming Magento is installed on the first domain).

There is a tutorial regarding it here:


Then edit your index.php file in the root of the Magento install

Replace the following code:

Mage::run($mageRunCode, $mageRunType);

With the following code:

switch ($_SERVER['HTTP_HOST']) {
    case 'www.domain1.com':
    case 'domain1.com':
        Mage::run('storeviewcode1', 'store');

    case 'www.domain2.com':
    case 'domain2.com':
        Mage::run('storeviewcode2', 'store');



Where storeviewcode1 is the store view code of the first store, and storeviewcode2 is the store view code of the second store.

Hope this helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.