0

编辑:问题是,我无法弄清楚我使用的是子域,我尝试只使用我的 TLD(纯)my.de 进行配置,瞧,它开箱即用。关于如何解决这个问题的任何想法?

我目前正在使用这个 nginx 配置在 Ubuntu 12.xx (VPS) 上的 nginx 1.3.x 上的 FastCGI (PHP-FPM) 上运行 OpenCart (v1.5.5.1) (PHP)。

当我尝试访问安装文件夹中的 index.php 时,如下所述:http://docs.opencart.com/display/opencart/Installation我最终陷入了无休止的重定向循环:

shop.mysite.com/install/shop.mysite.com/shop.mysite.com/.........etc/index.php

访问日志没有显示任何有用的信息,错误日志也没有显示任何内容。

# FORCE WWW
server {
    server_name  .shop.my.de;
    rewrite ^(.*) .shop.my.de$1 permanent;
}
# MAIN SERVER
server {
    error_log    /var/log/nginx/shop.my.de.error.log debug;
    access_log  /var/log/nginx/shop.my.de.access.log;
    server_name  .shop.my.de;
    listen 80;
    root /srv/opencart/upload;
    index index.php;

    location /install {
        index index.php;
    }
    location /image/data {
        autoindex on;
    }
    location /admin {
        index index.php;
    }
    location / {
        try_files $uri @opencart;
    }
    location @opencart {
        rewrite ^/(.+)$ /index.php?_route_=$1 last;
    }
    location = /favicon.ico {
        log_not_found off;
        #access_log off;
    }
    location = /robots.txt {
        allow all;
        #log_not_found off;
        #access_log off;
    }
    # Make sure files with the following extensions do not get loaded by nginx because nginx would display the source code, and these files can contain PASSWORDS!
    location ~* \.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(\..*|Entries.*|Repository|Root|Tag|Template)$|\.php_ {
        deny all;
    }
    # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
    location ~ /\. {
        deny all;
        #access_log off;
        #log_not_found off;
    }
    location ~*  \.(jpg|jpeg|png|gif|css|js|ico)$ {
        expires max;
        #log_not_found off;
    }
    location ~ \.php$ {
        try_files $uri =404;
        include /etc/nginx/fastcgi_params;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}
4

1 回答 1

1

解决方案是如果你想在子域上使用 NGINX + Opencart:如果你不这样做,opencart 会在重定向之间疯狂地反弹。

server {
    server_name  .shop.my.de;
    rewrite ^(.*) www.shop.my.de$1 permanent; # the www is the important thing!!
}

server {
    #..........
    server_name  www.shop.my.de; # also HERE! www is the important thing
    #..........
}
于 2013-05-23T23:56:27.533 回答