I am following tutorials about magento ,it use nginx as server ,I created 2 different stores and edit the file /etc/nginx/sites-available/magento as follows :
map $http_host $mage_run_code {
default '';
gizmo.com gizmo_com;
widget.com widget_com;
}
map $http_host $mage_run_type {
default store;
gizmo.com webisite;
widget.com website;
}
server {
listen 80;
root /var/www/magento;
index index.php index.html index.htm;
server_name magento.local gizmo.com www.gizmo.com widget.com www.widget.com;
# Place PHP error logs in the Magento log folder
set $php_log /var/www/magento/var/log/php_errors.log;
# Replaces Apache rewrite rules
location / {
try_files $uri $uri/ @handler;
}
# Protect sensitive folders
location /app/ { deny all; }
location /includes/ { deny all; }
location /lib/ { deny all; }
location /media/downloadable/ { deny all; }
location /pkginfo/ { deny all; }
location /report/config.xml { deny all; }
location /var/ { deny all; }
# Protect dotfiles (htaccess, svn, etc.)
location /. { return 404; }
location @handler {
rewrite / /index.php;
}
# Remove trailing slashes from PHP files
location ~ .php/ {
rewrite ^(.*.php)/ $1 last;
}
# Pass PHP to a the PHP-FPM backend
location ~ \.php$ {
# Fix timeouts when installing Magento via web interface
fastcgi_send_timeout 1800;
fastcgi_read_timeout 1800;
fastcgi_connect_timeout 1800;
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 on; # Turn on developer mode
fastcgi_param MAGE_RUN_CODE $mage_run_code;
fastcgi_param MAGE_RUN_TYPE $mage_run_type;
fastcgi_param PHP_VALUE error_log=$php_log;
include fastcgi_params;
}
}
The strange thing is ,that when I open widget.com it is not giving me error,but redirect me to magento.local/ ,actually the url stays widget.com ,but I tried to change the html of widget.com through the admin site of magento and it doesn't change so I think it loads the default magento index page.When I try to open gizmo.com it shows me 404 error.I restarted nginx and did everything as in the tutorial ,but still same thing.
Best Answer
This 'map' config is far from ideal. I've seen a few examples use the 'map' technique but it is really short sighted and full of general issues.
Best way to get mutli store running, start with one store, etc/nginx/sites-available/widget.com.conf and use the very basic nginx examples to get it running and in your the location ~ .php$ { location to point to the store name and check that it's still running:
When this is all working perfectly ? You can copy&past this config to /etc/nginx/sites-available/gizmo.com.conf
then change your store code to the other store in this config:
This will allow you to have a .config for each of your main stores. All based on a single proven store. With each having their own abilities, such as SSL/TLS and other really handy things for a webstore, like SiteMap locations etc. etc.)
Using this working example, you can add as many stores as you want by copying the working config and changing the store code in the php location block, each having their own .config file and each having their own settings where needed.
Here's a copy of my Nginx config to get you started:
Widgets.com.conf
gizmo.com.conf
You can see, by copying the config to a new file you now have full control over things like SSL/TLS and many other things you really should have for a eCommerce store.