Error 500 Without Nginx Error Log

April 15, 2017 498 views
Nginx PHP Ubuntu

I am trying to run a Silex app within a subdirectory on one of my droplets. While I understand there's plenty of results for this in google, nothing seems to work, so I'm hoping the community can help me out here. My server has two vhosts currently. A default that's setup on one domain, and another on another domain. I only mention there are two in case that seems to be part of my issue. My default host config:

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /usr/share/nginx/some.other.domain.name;
    index index.php index.html index.htm;

    server_name some.other.domain.name;

    location / {
        try_files $uri $uri/ =404;
    }

    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx/html;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }
}

Everything works fine with it. My other server is kind of a catch-all for projects I work on, so there's several subdirectories; all of them work fine, but there's also not much too them. They're either a monolithic quick and dirty php scripts and some are even just static html files. They all work fine, but the one subdirectory that uses Silex supposedly returns an Error 500. I say supposedly, because there's no error logged by nginx or php-fpm. I've changed log files around to make sure they were working and even triggered errors to make sure the files were writable. Everything works as expected. Literally all the other subdirectories simply work, but Silex needs to "rewrite" urls for index.php (from their docs). I've tried a number of things but this is where I've landed for the config:

server {
    listen 80;

    root /usr/share/nginx/some.awesome.domain.name;
    index index.php index.html index.htm;

    server_name some.awesome.domain.name;

    location / {
        try_files $uri $uri/ =404;
    }

    location /silexApp {
        try_files $uri /silexApp/index.php$is_args$args;

        location ~ ^/index\.php(/|$) {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
        }
    }

    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx/html;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }
}

Is there anything that stands out to anyone? Am I completely overlooking something?? I'm still new to Nginx.

1 Answer
anthonygreco April 21, 2017
Accepted Answer

FTR, this more or less works. It turns out I had some other extremely odd issue going on. Thank goodness for sys admin friends.

Have another answer? Share your knowledge.