Nginx下的子域名与Shopware

时间:2013-07-10 11:57:01

标签: nginx subdomain

您好,我有以下配置:

server {
listen 80;
server_name example.com;
client_max_body_size 24M;
client_body_buffer_size 128k;
server_name www.example.com;
root /www/example.com/htdocs/;

# Include shopware configuration.
include /www/example.com/config/shopware.conf;
}

server {
listen 80;
server_name subdomain.example.com;

client_max_body_size 24M;
client_body_buffer_size 128k;

root /www/example.com/subdomain/;

# Include shopware configuration.
include /www/example.com/config/shopware.conf;
}

server {
listen 443;
server_name example.com;

# SSL
ssl on;
ssl_certificate /etc/ssl/private/www.example.com.crt;
ssl_certificate_key /etc/ssl/private/www.example.com.key;
ssl_ciphers               SSLv3+HIGH:RC4+MEDIUM:!aNULL:!eNULL:!3DES:!MD5:@STRENGTH;
ssl_prefer_server_ciphers on;
ssl_protocols             SSLv3;
ssl_session_cache         shared:SSL:10m;

client_max_body_size 24M;
client_body_buffer_size 128k;

server_name example.com;
root /www/example.com/htdocs/;

# Include shopware configuration.
include /www/example.com/config/shopware.conf;
}

问题是当我尝试打开subdomain.example.com时,我得到一个NOT FOUND。

环境

nginx version: nginx/0.7.67
debian 6.0.7

shopware.conf:

## File: /etc/nginx/global/shopware.conf
## Author: Benjamin Cremer 
## Shopware 4 Nginx rules.
## Designed to be included in any server {} block.

location = /favicon.ico {
log_not_found off;
access_log off;
}

location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}

location = /templates/_default/backend/_resources/resources/css/icon-set.css {
gzip off;
}

## Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}

## Deny all attems to access possible configuration files
location ~ \.(tpl|yml|ini)$ {
deny all;
}

## Deny access to media upload folder
location ^~ /media/temp/ {
deny all;
}

location ^~ /cache/ {
deny all;
}

location ^~ /files/documents/ {
deny all;
}

# Breaks backend/media/ rewrite
#
#location ~ /(engine|files|templates|media)/ {
#    location ~ \.php$ {
#        return 403;
#    }
#}

location /check/ {
index index.php;
try_files $uri /check/index.php?$args;
}

location /install {
index index.php;
try_files $uri /install/index.php?$args;
}


location / {
index index.html index.php shopware.php
            rewrite shopware.dll /shopware.php;
            rewrite files/documents/.* /engine last;
            rewrite images/ayww/(.*) /images/banner/$1 last;
            rewrite backend/media/(.*) media/$1 last;
            if (!-e $request_filename){
                rewrite . /shopware.php last;
            }
## Defining rewrite rules
# rewrite ^ https://www.kotel.de permanent;
#rewrite files/documents/.* /engine last;
#rewrite backend/media/(.*) /media/$1 last;

location ~* ^.+\.(?:css|js|jpe?g|gif|ico|png|html|xml)$ {
    expires 1w;
    add_header Pragma public;
    add_header Cache-Control "public, must-revalidate, proxy-revalidate";

    access_log off;



    # The directive enables or disables messages in error_log about files not found on disk.
    log_not_found off;

    tcp_nodelay off;
    ## Set the OS file cache.
    open_file_cache max=3000 inactive=120s;
    open_file_cache_valid 45s;
    open_file_cache_min_uses 2;
    open_file_cache_errors off;
}

index shopware.php index.php;
try_files $uri $uri/ /shopware.php?$args;
}

## XML Sitemap support.
location = /sitemap.xml {
try_files $uri /shopware.php?controller=SitemapXml;
}

location ~ \.php$ {
try_files $uri =404;

## NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
fastcgi_split_path_info ^(.+\.php)(/.+)$;

#fastcgi_keep_conn on;

fastcgi_param SCRIPT_FILENAME$document_root$fastcgi_script_name;
include fastcgi_params;

fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;

fastcgi_pass php-fpm;
}

任何人都可以给我一些安慰,我做错了吗?

谢谢, 史蒂芬

1 个答案:

答案 0 :(得分:0)

当你在conf中列出时,你的子域就像这样

server {
    listen 80;
    server_name subdomain.example.com;

    client_max_body_size 24M;
    client_body_buffer_size 128k;

    root /www/example.com/subdomain/;

    # Include shopware configuration.
    include /www/example.com/config/shopware.conf;
}

编辑: 所以在shopware.conf里面有一行显示fastcgi_pass php-fpm;,我不确定这是否正常工作,如果你遇到错误的网关错误,那么这就是你需要解决的问题,尝试将其替换为这些行中的任何一行,看看哪些有用

fastcgi_pass unix:/var/run/php5-fpm.sock;

fastcgi_pass 127.0.0.1:9000;

我认为其中一个应该有效