在NGINX conf中找不到“GET /”的路由

时间:2014-10-01 16:08:19

标签: php symfony nginx configuration location

(首先,对不起英语,这不是我的母语:/)

我的NGINX conf有问题,我在2个文件夹中有2个symfony2项目。第一个是我的根目录(www.mywebsite.com/)在我的nginx conf中,我想第二个就像这样www.mywebsite.com/secondwebsite。

第一个网站在端口80上工作正常(使用经典的nginx配置)。

我的第二个网站在端口82(www.mywebsite.com:82)上运行良好,例如使用此conf:

server {
    listen 82;
    server_name mywebsite.com *.mywebsite.;
    root /var/www/project/dev/secondwebsite/web/;
    index app_dev.php;
    location / {
            # try to serve file directly, fallback to app.php
            try_files $uri /app_dev.php$is_args$args;
    }
    location ~ \.php$ {
            try_files $uri =404;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_buffer_size 128k;
            fastcgi_buffers 4 256k;
            fastcgi_busy_buffers_size 256k;
            include         fastcgi_params;
            add_header Access-Control-Allow-Origin *;
    }
}

但是当我尝试访问这样的www.mywebsite.com/secondwebsite时,我遇到了一个问题,我所有的symfony2路由都不起作用(我每个都得到404),我把我的app_dev.php作为索引来获得更多细节

这是我的nginx conf的配置:

server {
    listen 80;
    server_name mywebsite.com *.mywebsite.com;
    index app.php;
    root /var/www/project/dev/mywebsite/web;
    error_log /var/log/nginx/mywebsite.error.log;
    access_log /var/log/nginx/mywebsite.access.log;
    if ($http_host != "www.mywebsite.com"){
            rewrite ^ http://www.mywebsite.com$request_uri permanent;
    }
    location / {
            # try to serve file directly, fallback to app.php
            try_files $uri /app.php$is_args$args;
    }
    location /secondwebsite/ {
            alias /var/www/project/dev/secondwebsite/web/;
            index app_dev.php;
            location ~ \.php$ {
                    fastcgi_pass   127.0.0.1:9000;
                    fastcgi_index  app_dev.php;
                    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                    include         fastcgi_params;
                    add_header Access-Control-Allow-Origin *;
            }
    }
    location ~ \.php$ {
            try_files $uri =404;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_buffer_size 128k;
            fastcgi_buffers 4 256k;
            fastcgi_busy_buffers_size 256k;
            include         fastcgi_params;
            add_header Access-Control-Allow-Origin *;
    }
}

我已多次搜索但没有任何作用,我真的需要帮助^^

0 个答案:

没有答案