4

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:
http://blog.sina.com.cn/s/blog_dbc356910101blfg.html

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.

QuestionsQuestions
3091 gold badge2 silver badges14 bronze badges
asked Mar 4, 2015 at 21:31
2
  • 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. Commented 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? Commented Mar 5, 2015 at 23:08

3 Answers 3

11

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;
answered Feb 2, 2016 at 11:16
1
  • Which file i need to update above lines, nginx.conf.sample or etc/nginx/conf.d/magento.conf? @MagenX Commented Jun 30, 2020 at 12:40
4

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

map $http_host $magecode {
 hostnames;
 .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.$host1ドル;}
 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_pass 127.0.0.1:9000;
 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
 }
}
answered Mar 5, 2015 at 14:23
4
  • Nice! I definitely prefer mapping over host switch! Commented 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 Commented Aug 11, 2016 at 13:41
  • @YogeshTrivedi Where are you inserting the map block? It should be inside the http block. Commented 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 Commented Sep 14, 2018 at 1:51
0

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:

https://support.getcloudservices.com/entries/25925119-Plesk-Web-Hosting-Configure-A-Domain-Alias-Pointer-Domain-

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');
 break;
 case 'www.domain2.com':
 case 'domain2.com':
 Mage::run('storeviewcode2', 'store');
 break;
 default:
 Mage::run();
 break;
}

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!

answered Sep 23, 2015 at 22:31

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.