Nginx错误404 - 带有Vagrant的Symfony2

时间:2015-06-07 14:06:05

标签: symfony nginx vagrant

我安装了一台带有Symfony和NGINX的新鲜流浪汉机器,但是在我得到之后:

// Opened: http://project.app/app_dev.php 

https://cl.ly/image/3D2M1N1h1W0f

404 NOT FOUND

// Opened http://project.app/app.php or http://project.app

https://cl.ly/image/3G0Q47240G0p

我的nginx配置:

server {
        listen 80;

        root /vagrant/symfony/web;
        index index.html index.htm index.php app.php app_dev.php;

        # Make site accessible from ...
        server_name 192.168.22.10.xip.io handshake.dev;

        access_log /var/log/nginx/vagrant.com-access.log;
        error_log  /var/log/nginx/vagrant.com-error.log error;

        charset utf-8;

        location / {
            try_files $uri $uri/ /app.php?$query_string /index.php?$query_string;
        }

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

        error_page 404 /index.php;

        # pass the PHP scripts to php5-fpm
        # Note: .php$ is susceptible to file upload attacks
        # Consider using: "location ~ ^/(index|app|app_dev|config).php(/|$) {"
        location ~ .php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+.php)(/.+)$;
            # With php5-fpm:
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param LARA_ENV local; # Environment variable for Laravel
            fastcgi_param HTTPS off;
        }

        # Deny .htaccess file access
        location ~ /\.ht {
            deny all;
        }
    }

    server {
        listen 443;

        ssl on;
        ssl_certificate     /etc/ssl/xip.io/xip.io.crt;
        ssl_certificate_key /etc/ssl/xip.io/xip.io.key;

        root /vagrant/symfony/web;
        index index.html index.htm index.php app.php app_dev.php;

        # Make site accessible from ...
        server_name 192.168.22.10.xip.io handshake.dev;

        access_log /var/log/nginx/vagrant.com-access.log;
        error_log  /var/log/nginx/vagrant.com-error.log error;

        charset utf-8;

        location / {
            try_files $uri $uri/ /app.php?$query_string /index.php?$query_string;
        }

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

        error_page 404 /index.php;

        # pass the PHP scripts to php5-fpm
        # Note: .php$ is susceptible to file upload attacks
        # Consider using: "location ~ ^/(index|app|app_dev|config).php(/|$) {"
        location ~ .php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+.php)(/.+)$;
            # With php5-fpm:
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
          include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param LARA_ENV local; # Environment variable for Laravel
            fastcgi_param HTTPS on;
        }

        # Deny .htaccess file access
        location ~ /\.ht {
            deny all;
        }
    }

我错了什么?

更新: 直接打开IP / URL而没有app_dev.php我现在得到了:

403 Forbidden

是的,我有routing.yml,是的,我有Bundles。

0 个答案:

没有答案