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

Become a contributor for community

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

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.