Question

Error 500 Without Nginx Error Log

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.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

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

please I have a big problem with error 500 and no luck with the logs.i had deleted all the logs and suddenly nothing seems to show in them anymore.can anyone help

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel