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.
-
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– SR_Magento2015年03月04日 21:55:21 +00:00Commented 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?brentwpeterson– brentwpeterson2015年03月05日 23:08:57 +00:00Commented 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? @MagenXzus– zus2020年06月30日 12:40:47 +00:00Commented 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 {
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
}
}
-
Nice! I definitely prefer mapping over host switch!MauroNigrele– MauroNigrele2015年12月28日 21:24:40 +00:00Commented 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.samplYogesh Trivedi– Yogesh Trivedi2016年08月11日 13:41:28 +00:00Commented Aug 11, 2016 at 13:41
-
@YogeshTrivedi Where are you inserting the map block? It should be inside the http block.Phil Birnie– Phil Birnie2017年06月01日 19:05:52 +00:00Commented Jun 1, 2017 at 19:05
-
1Note. if you run your admin on a separate domain then MAGE_RUN_TYPE needs to be set to storeben.incani– ben.incani2018年09月14日 01:51:59 +00:00Commented 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');
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!