【问题标题】:Nginx - Magento multiple websitesNginx - Magento 多个网站
【发布时间】:2012-08-26 03:33:28
【问题描述】:

我安装了一个包含多个网站的 Magento,它在 Apache Web 服务器中运行。 现在我想将这些移动到 Nginx 网络服务器;如何通过 Nginx 配置实现这一点? 以下是重定向网站的 htaccess 代码:

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

请帮忙。

【问题讨论】:

    标签: .htaccess magento nginx webserver


    【解决方案1】:

    .htaccessSetEnvIf 用于 Apache Web 服务器。对于 Nginx,您可以使用 fastcgi_param(如果您使用 fastcgi 运行 nginx)。

    您可以在此处找到更多详细信息: http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/configuring_nginx_for_magento

    【讨论】:

      【解决方案2】:

      要在具有不同端口的同一服务器上运行 2 个 Magento 网站,您必须为 /etc/nginx/conf.d/ 下的每个端口使用 2 个不同的 nginx 配置文件。

      从提供的示例来看,您似乎在端口 80 和 8080 上运行网站。Magento 在http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/configuring_nginx_for_magento 处提供了默认的 nginx 配置

      将此用于端口 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; 
          }
      }
      

      【讨论】:

      • 此外,我们在本文中添加了更多关于如何执行此操作(背后的逻辑)的信息 - blog.magepsycho.com/…
      【解决方案3】:

      商店代码在管理 > 配置 > 管理商店中定义

      fastcgi_param  MAGE_RUN_CODE default;
      fastcgi_param  MAGE_RUN_TYPE store;
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-07-26
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多