2012-08-31 115 views
1

我有一個Magento安裝與多個網站,這是運行在Apache Web服務器。 現在我想將這些移動到Nginx Web服務器;我怎麼用Nginx配置來實現這個功能? 下面是該網站重定向htaccess的代碼:Nginx的Magento多個網站

SetEnvIf HOST 44\.55\.222\.101\:8080 MAGE_RUN_CODE=website_new 
SetEnvIf HOST 44\.55\.222\.101\:8080 MAGE_RUN_TYPE=website 

請幫助。

回答

2

要與你B平均值使用2個不同的nginx的配置文件,爲每個端口/etc/nginx/conf.d/下不同的端口在同一臺服務器上運行2個Magento的網站。

從例如提供好像你正在運行的端口80和8080 Magento的網站在這裏提供的默認nginx的配置在http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/configuring_nginx_for_magento

使用此端口80和8080使用下面的代碼:

server { 
    listen 8080 default; 
    server_name 44.55.222.101; 
    root /var/www/html; 
    location/{ 
     index index.php index.html index.htm; 
     try_files $uri $uri/ @handler; 
     expires 30d; 
    } 
    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; } 
    location /var/export/ { 
     auth_basic   "Restricted"; 
     auth_basic_user_file htpasswd; 
     autoindex   on; 
    } 
    location /. { 
     return 404; 
    } 
    location @handler { 
     rewrite//index.php; 
    } 
    location ~ .php/ { 
     rewrite ^(.*.php)/ $1 last; 
    } 
    location ~ .php$ { 
     if (!-e $request_filename) { rewrite//index.php last; } 
     expires  off; 
     fastcgi_pass 127.0.0.1:9000; 
     fastcgi_param HTTPS $fastcgi_https; 
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
     fastcgi_param MAGE_RUN_CODE website_new; 
     fastcgi_param MAGE_RUN_TYPE website; 
     include  fastcgi_params; 
    } 
} 
+0

此外,我們還增加了關於如何做到這一點的詳細信息(背後的邏輯)在這篇文章 - http://www.blog.magepsycho.com/set-multiple-magento-2-websites-stores-nginx/ – MagePsycho

2

店內碼在管理>配置定義>管理房屋

fastcgi_param MAGE_RUN_CODE default; 
fastcgi_param MAGE_RUN_TYPE store;