Magento有nginx的多家商店

时间:2016-04-20 19:34:06

标签: php magento nginx

我正在关注magento的教程,它使用nginx作为服务器,我创建了2个不同的商店并编辑文件/ etc / nginx / sites-available / magento,如下所示:

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;
    }
}

奇怪的是,当我打开widget.com时它并没有给我错误,而是将我重定向到magento.local /,实际上url保留了widget.com,但我试图更改widget.com的html通过magento的管理站点,它没有改变,所以我认为它加载默认的magento索引页面。当我尝试打开gizmo.com它显示我404错误。我重新启动nginx并做了教程中的所有内容,但还是一样的。

1 个答案:

答案 0 :(得分:0)

map $http_host $mage_run_code {
    default '';
    gizmo.com gizmo_com; // Make sure this is the correct store view code
    widget.com widget_com; // Make sure this is the correct store view code
}
// Remove all this bellow
map $http_host $mage_run_type {
    default store;
    gizmo.com webisite; // BTW, this typo might be causing the 404
    widget.com website;
}
// ..
...
...

server_name magento.local .... // No need for this name (magento.local)

...
...

最后改变一下:

fastcgi_param MAGE_RUN_TYPE $mage_run_type;

fastcgi_param MAGE_RUN_TYPE store;

给它一个测试,让我知道会发生什么