Symfony 2 nginx configuraiton выдает ошибку 500

1

Это моя конфигурация:

server {
    server_name domain.com;
    root /var/www/domain.com/web;

    location / {
        # try to serve file directly, fallback to app.php
        try_files $uri /app.php$is_args$args;
    }
    # DEV
    # This rule should only be placed on your development environment
    # In production, don't include this and don't deploy app_dev.php or config.php
    location ~ ^/(app_dev|config)\.php(/|$) {
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        # When you are using symlinks to link the document root to the
        # current version of your application, you should pass the real
        # application path instead of the path to the symlink to PHP
        # FPM.
        # Otherwise, PHP OPcache may not properly detect changes to
        # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
        # for more information).
        fastcgi_param  SCRIPT_FILENAME  $realpath_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;
    }
    # PROD
    location ~ ^/app\.php(/|$) {
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        # When you are using symlinks to link the document root to the
        # current version of your application, you should pass the real
        # application path instead of the path to the symlink to PHP
        # FPM.
        # Otherwise, PHP OPcache may not properly detect changes to
        # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
        # for more information).
        fastcgi_param  SCRIPT_FILENAME  $realpath_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;
        # Prevents URIs that include the front controller. This will 404:
        # http://domain.tld/app.php/some-path
        # Remove the internal directive to allow URIs like this
        internal;
    }

    error_log /var/log/nginx/domain.com.error.log;
    access_log /var/log/nginx/domain.com.access.log;
}

Сайт электронной почты работает, domain.com/, но всякий раз, когда я открываю любой другой маршрут, например domain.com/test/ я получаю 500 внутренних ошибок сервера.

Кроме того, когда я открываю среду dev, например domain.com/app_dev.php/test/ я получаю сообщение об ошибке, что я не могу получить доступ app_dev.php файлу app_dev.php.

Что не так?

  • 0
    Он может работать как официальная конфигурация nginx от symfony.com , поэтому не могли бы вы предоставить дополнительную информацию о вашем приложении, например, свой контроллер и файл routing.yml ? Что касается app_dev.php - доступ к этому файлу закрыт из не localhost по соображениям безопасности, вы можете посмотреть код самостоятельно и даже снять защиту, если вам нужно.
  • 0
    Также вы можете просмотреть свои журналы: /var/log/nginx/domain.com.error.log и /var/www/domain.com/app/logs/prod.log для получения дополнительной информации.
Показать ещё 4 комментария
Теги:
nginx

1 ответ

0

Попробуй это:

server {
listen                *:80;

server_name           time.dev www.time.dev;
client_max_body_size 1m;

root /var/www/time/web;
   index  app_dev.php;

access_log            /var/log/nginx/xxx_time.access.log;
error_log             /var/log/nginx/xxx_time.error.log;

location ~ \.php$ {

  root  /var/www/time/web;
  fastcgi_index app_dev.php;
  fastcgi_split_path_info ^(.+\.php)(/.*)$;
  try_files $uri $uri/ /app_dev.php$is_args$args;
  include /etc/nginx/fastcgi_params;
  fastcgi_pass 127.0.0.1:9000;

  fastcgi_param SCRIPT_FILENAME $request_filename;
  fastcgi_param APP_ENV dev;

}
location / {
    root  /var/www/time/web;
    try_files $uri $uri/ /app_dev.php$is_args$args;
    autoindex off;
    index  index.html index.htm index.php;


  }
  sendfile off;
}

Он скопировал мою машину-бродягу.

https://gist.github.com/sfarkas1988/f781ef3015f7d794b6b2

  • 2
    Пожалуйста, объясните, почему ваша конфигурация лучше официальной.

Ещё вопросы

Сообщество Overcoder
Наверх
Меню