Welcome! Log In Create A New Profile

Advanced

NginX works with an index.php file, but not with the other

Posted by bertalanimre 
NginX works with an index.php file, but not with the other
November 13, 2015 05:31AM
Hello Guys,

I have been given a task to migrate a very old website to a new server. The old server was using PHP 5.4, the new one is using PHP 5.6, but this is not the issue I think. My main problem is, if I set up the NginX config nicely the browser gives me an internal server error code 500. Not NginX, the browser doesn't even gets there and the logs do not log anything.
HOWEVER: If I change only the root path to somewhere inside the original root and I create a PHPInfo file as index.php, then that IS displayed in the browser without any errors.
How come the browser can see the "website" correctly if it is set to the phpinfo index.php, but can't even get to NginX if it points to the original index.php?

Here is the NginX conf file with some details outlined:
http://pastebin.com/3MJC79q3

-----------------------------------------------------
-----------------------------------------------------
More than 50% of the US citizens belive that the bad weather can interrupt your connection to the cloud servers.
Re: NginX works with an index.php file, but not with the other
November 13, 2015 06:09AM
What do the logfiles say?

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: NginX works with an index.php file, but not with the other
November 13, 2015 06:43AM
This is the best part. Nothing.
Since the web browser doesn't even reach NginX, the NginX logs don't show anything. And if it points to the same locations subfolder with another index.php, then there is no error, so no logging again.

-----------------------------------------------------
-----------------------------------------------------
More than 50% of the US citizens belive that the bad weather can interrupt your connection to the cloud servers.
Re: NginX works with an index.php file, but not with the other
November 13, 2015 06:51AM
You have to see something in nginx logfiles, if not then your requests are not reaching nginx but are blocked by something else in front of nginx.

btw.:
access_log /var/log/nginx/hu.MYCOMPANY.MYSITE/access.log;
access_log on;

Is not helpful for logging :-) unless you wanted a file named 'on'

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: NginX works with an index.php file, but not with the other
November 13, 2015 07:19AM
Ok, I'll correct myself then. :) Access.log is indeed loggins something, but I think this is not helping at all. This is what it logs if I view the website:
37.220.134.162 - euro [13/Nov/2015:13:18:25 +0100] "GET / HTTP/1.1" 500 5 "-" "Mozilla/5.0 (X11; Fedora; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.71 Safari/537.36"
37.220.134.162 - euro [13/Nov/2015:13:18:26 +0100] "GET / HTTP/1.1" 500 5 "-" "Mozilla/5.0 (X11; Fedora; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.71 Safari/537.36"

-----------------------------------------------------
-----------------------------------------------------
More than 50% of the US citizens belive that the bad weather can interrupt your connection to the cloud servers.
Re: NginX works with an index.php file, but not with the other
November 13, 2015 07:23AM
Enable debug logging (for error.log) to see where/what is causing the 500.
error_log /var/log/nginx/hu.MYCOMPANY.MYSITE/error.log debug;

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: NginX works with an index.php file, but not with the other
November 13, 2015 07:29AM
This is intresting. And shows my newbie-ness to NginX right now. Completly forgot, to set the error level to debug mode. It showed me the following:

2015/11/13 13:28:06 [notice] 26645#0: *1 "^/(.+)/$" does not match "/index.php", client: XXX.XXX.XXX.XXX, server: MYSITE.MYCOMPANY.hu, request: "GET / HTTP/1.1", host: "MYSITE.MYCOMPANY.hu"

-----------------------------------------------------
-----------------------------------------------------
More than 50% of the US citizens belive that the bad weather can interrupt your connection to the cloud servers.
Re: NginX works with an index.php file, but not with the other
November 13, 2015 08:05AM
Now I've commented out the following lines so they will be ignored:

# if (!-d $request_filename) {
# rewrite ^/(.+)/$ /$1 permanent;
# }


Now, the browser sais Internal Server error again, but absolutely no log at all. Only the same as previously mentioned in the access.log

-----------------------------------------------------
-----------------------------------------------------
More than 50% of the US citizens belive that the bad weather can interrupt your connection to the cloud servers.
Re: NginX works with an index.php file, but not with the other
November 13, 2015 09:41AM
Cleared the browser cache? debugging like this is best done with Curl, as you also will see the headers.

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: NginX works with an index.php file, but not with the other
November 13, 2015 10:33AM
I'm using Chrome and I always open an incognito windows to check. I have no other idea :/ But this frustrates me a lot. Just a reminder: The webpage was working in an Ubuntu, PHP 5.4 environment. Not this new system is CentOS 7 and PHP 5.6. Can this cause the issue? (Even tho I've modified the NginX config file to make it work, and this is not the only website migrated, but this is the only one not working at all.

-----------------------------------------------------
-----------------------------------------------------
More than 50% of the US citizens belive that the bad weather can interrupt your connection to the cloud servers.
Re: NginX works with an index.php file, but not with the other
November 13, 2015 11:02AM
Could be, selinux policies in place? if a request reaches nginx then it will log this.

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: NginX works with an index.php file, but not with the other
November 13, 2015 11:18AM
I don't think so, but will check it.
Why and how would SELinux (whoever invented it, I would smak him int he face with a wet fish...) block only one website ot of 20 ? I have 20 others, almost 10 was migrated from the same server and they work just fine....

-----------------------------------------------------
-----------------------------------------------------
More than 50% of the US citizens belive that the bad weather can interrupt your connection to the cloud servers.
Re: NginX works with an index.php file, but not with the other
November 13, 2015 11:43AM
Don't shoot the messenger ;-) most likely it is still a nginx.conf issue but that also means it most be loggable.

---
nginx for Windows http://nginx-win.ecsds.eu/
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 79
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready