unmark icon indicating copy to clipboard operation
unmark copied to clipboard

Suggested nginx config not working on Ubuntu 16.04 + nginx 1.10 + PHP7.0

Open neopostmodern opened this issue 8 years ago • 12 comments

I was getting a blank page and 200 for everything.

After adding the following line as suggested on StackOverflow somewhere I got it to work:

fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name

Not sure if this is necessary for all versions, but maybe add a hint?

neopostmodern avatar Oct 17 '16 20:10 neopostmodern

@neopostmodern Perhaps you can suggest an update for the Readme?

cdevroe avatar Oct 18 '16 14:10 cdevroe

Will do. Maybe someone with proper nginx knowledge could comment if that could be added to the default config or if it's platform specific?

neopostmodern avatar Oct 18 '16 14:10 neopostmodern

Tested on Ubuntu 16.04 and saw the same behaviour you described (200OK with blank page)

Then I added your suggested line to the nginx config and unmark loaded right up fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;

I've also tested this line works as well: fastcgi_param SCRIPT_FILENAME $request_filename; http://serverfault.com/questions/502776/what-is-the-correct-setting-of-nginxs-fastcgi-param-script-filename

I'm also running unmark on Ubuntu 14.04 on nginx and the /etc/nginx/fastcgi_params file has: fastcgi_param SCRIPT_FILENAME $request_filename;

I'm not an nginx expert by any means, but based on documentation on the nginx site of some examples, I propose the addition of the following line to the unmark nginx readme. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

moltenkaizen avatar Oct 19 '16 18:10 moltenkaizen

I also just recognized the following:

$ ls /etc/nginx | grep fastcgi
fastcgi.conf
fastcgi_params

and further

$ diff fastcgi_params fastcgi.conf 
1a2
> fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;

...which basically says that there is another file (fastcgi.conf) that includes the required line.

Researching if this was safe to use, I found this blog entry:

In 0.8.30 (released: 15th of December 2009) Igor then included fastcgi.conf which was the same as fastcgi_params except including the improved SCRIPT_FILENAME fastcgi_param. This meant that the community could now start recommending people include fastcgi.conf instead of recommending moving SCRIPT_FILENAME into fastcgi_params. New articles on the wiki mostly used this, the popular articles were slowly changed to use it and we were promoting it in the IRC support channel.

Long story short, maybe it's a better fix to change the inclusion.

neopostmodern avatar Oct 19 '16 19:10 neopostmodern

Very interesting, I see that's the only difference between those files. I see what you mean on my Ubuntu 16 as well.

I'm also comparing that to Ubuntu 14.04, I don't have a fastcgi.conf. But their fastcgi_params already had the line fastcgi_param SCRIPT_FILENAME $request_filename; which seems to work like fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name

Changing the include on Ubuntu 16 makes sense. Maybe a few notes could be added to the readme to give tips on working basic nginx configs for a few common distros. This fixes Ubuntu 16 but would break 14. include /etc/nginx/fastcgi.conf;

moltenkaizen avatar Oct 19 '16 20:10 moltenkaizen

Wow, I had included that blog post because 2009 sounded like it would have landed everywhere, but... well.

Proposal, to be included right below the sample code:

The content of /etc/nginx/fastcgi_params appeares to be distro dependent. Make sure yours includes a fastcgi_param SCRIPT_FILENAME line (e.g. by running cat /etc/nginx/fastcgi_params | grep SCRIPT_FILENAME). Should you be missing this line you can try to replace include /etc/nginx/fastcgi_params; with include /etc/nginx/fastcgi.conf;, in case your distro ships it. Otherwise, please add fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; to your nginx configuration. For further discussion refer to #181.

neopostmodern avatar Oct 19 '16 21:10 neopostmodern

@neopostmodern Looks great to me. I'd make a very minor tweak

grep SCRIPT_FILENAME /etc/nginx/fastcgi_params Just a touch more concise

@cdevroe thoughts?

moltenkaizen avatar Oct 19 '16 22:10 moltenkaizen

@neopostmodern did you get this working in the end?

weaktyper avatar Dec 14 '16 13:12 weaktyper

Doing this enabled me to access the site, but this SQL issue remains and I'm reluctant to change all the modes, so I haven't been able to use it on my machine.

This issue was really all about changing the documentation.

neopostmodern avatar Dec 14 '16 13:12 neopostmodern

Changing include /etc/nginx/fastcgi_params; to include /etc/nginx/fastcgi.conf; worked for me.

Has anybody make pull request about the fix already?

mclang avatar Dec 15 '16 18:12 mclang

Changing include /etc/nginx/fastcgi_params; to include /etc/nginx/fastcgi.conf; worked for me.

Has anybody make pull request about the fix already?

mclang avatar Dec 16 '16 07:12 mclang

I made some changes according to new Nginx documentation.

I hope I got it right!

mclang avatar Dec 16 '16 09:12 mclang