@richb-hanover opened this Issue on July 8th 2016

Installing Piwik 2.16.1 on Ubuntu 14.04.4 LTS. It's my own VPS (with root access). (This is information from https://forum.piwik.org/t/new-install-of-piwik-2-16-1-receive-get-request-to-piwik-php-failed/20115/1)

I am stuck at the System Check page that displays the message above (screen shot below). Here is my installation process:

I then connect to my host in my browser to start the web-based installation. I get to the System Check page and see the 500 Error for Tracker Status with the "GET request to piwik.php failed." message.

I do not have HTTP Authentication or mod_security running on this host (at least, none of the other virtual hosts see these errors.) Further troubleshooting:

  • When I browse to my site http://example.com/piwik.php, I get a 500 Server error
  • The error.log file contains the message below.
  • There is no file named /var/www/piwik/config/config.ini.php (consistent with error.log message below)
  • There is a file named /var/www/piwik/config/global.ini.php.

Any thoughts?

Relevant line from error.log file

[Thu Jul 07 08:57:54.337334 2016] [:error] [pid 28290] [client 64.222.236.200:60707] PHP Fatal error: Uncaught exception 'Exception' with message 'The configuration file {/var/www/piwik/config/config.ini.php} has not been found or could not be read.' in /var/www/piwik/core/Application/Kernel/EnvironmentValidator.php:63\nStack trace:\n<a href='/0'>#0</a> /var/www/piwik/core/Application/Kernel/EnvironmentValidator.php(44): Piwik\\Application\\Kernel\\EnvironmentValidator->checkConfigFileExists('/var/www/piwik/...', false)\n<a href='/1'>#1</a> /var/www/piwik/core/Application/Environment.php(185): Piwik\\Application\\Kernel\\EnvironmentValidator->validate()\n<a href='/2'>#2</a> /var/www/piwik/core/Application/Environment.php(94): Piwik\\Application\\Environment->validateEnvironment()\n<a href='/3'>#3</a> /var/www/piwik/piwik.php(56): Piwik\\Application\\Environment->init()\n<a href='/4'>#4</a> {main}\n thrown in /var/www/piwik/core/Application/Kernel/EnvironmentValidator.php on line 63

Screen shot of the error message on the System Check page

image

@ZacharyDuBois commented on July 9th 2016

I am having this issue too.

Ubuntu 14.04
Nginx: nginx/1.10.1
Piwik 2.16.1
PHP-FPM 7.0.8-3+deb.sury.org~trusty+1

Error log

2016/07/09 13:00:45 [error] 5714<a href='/5714'>#5714</a>: *34 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Exception: The configuration file {/srv/http/telemetry/public/config/config.ini.php} has not been found or could not be read. in /srv/http/telemetry/public/core/Application/Kernel/EnvironmentValidator.php:63
Stack trace:
<a href='/0'>#0</a> /srv/http/telemetry/public/core/Application/Kernel/EnvironmentValidator.php(44): Piwik\Application\Kernel\EnvironmentValidator->checkConfigFileExists('/srv/http/telem...', false)
<a href='/1'>#1</a> /srv/http/telemetry/public/core/Application/Environment.php(185): Piwik\Application\Kernel\EnvironmentValidator->validate()
<a href='/2'>#2</a> /srv/http/telemetry/public/core/Application/Environment.php(94): Piwik\Application\Environment->validateEnvironment()
<a href='/3'>#3</a> /srv/http/telemetry/public/piwik.php(56): Piwik\Application\Environment->init()
<a href='/4'>#4</a> {main}
  thrown in /srv/http/telemetry/public/core/Application/Kernel/EnvironmentValidator.php on line 63" while reading response header from upstream, client: [redacted], server: telemetry.zacharydubois.moe, request: "GET /piwik.php?url=http://example.com HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "telemetry.zacharydubois.moe"
@csaeum commented on July 9th 2016

the same here
Nginx: nginx/1.10.1
Piwik 2.16.1
Debian 8
PHP-FPM 5.6

@tsteur commented on July 10th 2016 Owner

Do you actually get that error when you request piwik.php on that server or is it maybe from another request when eg opening the installer the first time? I just downloaded a copy of 2.16.1 and everything works fine for me. Our automated tests work as well. It must be a server related issue. Can you see anything else in the logs?

Looking at the code it must think it is in CLI mode. Can you try to replace the first line here https://github.com/piwik/piwik/blob/2.16.1/core/Common.php#L129 with return false; and give it another try?

@richb-hanover commented on July 11th 2016

Do you actually get that error when you request piwik.php on that server or is it maybe from another request when eg opening the installer the first time?

Thanks for your response. Yes, If I request http://myserver.com/piwik.php, the web browser inspector shows a 500 error. This happens if I rm -rf the piwik directory and unzip it again.

I just downloaded a copy of 2.16.1 and everything works fine for me. Our automated tests work as well. It must be a server related issue. Can you see anything else in the logs?

The only related messages are identical to the one shown in the original post.

Looking at the code it must think it is in CLI mode. Can you try to replace the first line here https://github.com/piwik/piwik/blob/2.16.1/core/Common.php#L129 with return false; and give it another try?

Replacing line 129 completely (that's the line with if (is_bool(self::$isCliMode)) { ) would give a syntax error. I inserted return false; above line 129 and got a complaint that the file-length check failed, and that perhaps the file was corrupted.

Do you have any explanation for the message that indicates that the config file /var/www/piwik/config/config.ini.php is missing?

@ZacharyDuBois commented on July 11th 2016

Yes, it does 500 on my setup. It has to be caused by a syntax error somewhere as I just ignored the error and proceeded with the install, piwik.php returns correctly with a 400 "Bad Request" when requesting http://telemetry.domain.tld/piwik.php?url=http://example.com

@tsteur commented on July 11th 2016 Owner

Replacing line 129 completely (that's the line with if (is_bool(self::$isCliMode)) { ) would give a syntax error. I inserted return false; above line 129 and got a complaint that the file-length check failed, and that perhaps the file was corrupted.

@richb-hanover does it maybe still work when you add it above the line? The error message re file-length check could be ignored in this case. It's just to see where the problem is as we cannot reproduce it. Or maybe someone can give us access to one of the servers that has such a problem?

It is expected that config.ini.php is missing before the installation as it is only created during the installation. There is some logic to ignore this error in piwik.php and it is not supposed to trigger an error when Piwik is not installed yet.

@richb-hanover commented on July 11th 2016

Thanks for keeping an eye on this.

Could this be a file permission problem? What permissions should be set on the piwik directory/subdirectories? Thanks.

@mattab commented on July 11th 2016 Owner

@richb-hanover just to confirm: have you already installed piwik, your file config.ini.php is created, looks correct, is readable by the web server user, and still you get this message The configuration file {/var/www/piwik/config/config.ini.php} has not been found or could not be read. ?

@richb-hanover commented on July 12th 2016

I'm not quite sure how to describe the state (I'm not sure if piwik is "installed" or not). I installed piwik using the steps in the initial post above. (unzip, chown, chgrp, then connect with a web browser to begin the web-based install.) Here is the contents of /var/www/piwik/config when I get to the System Check page:

$ ls -al /var/www/piwik/config/
total 736
drwxr-xr-x  3 www-data www-data   4096 Apr 11 16:48 .
drwxr-xr-x 12 www-data www-data   4096 Apr 11 16:48 ..
drwxr-xr-x  2 www-data www-data   4096 Dec 23  2015 environment
-rw-r--r--  1 www-data www-data  39622 Apr 11 16:48 global.ini.php
-rw-r--r--  1 www-data www-data   3102 Nov 18  2015 global.php
-rw-r--r--  1 www-data www-data 695889 Apr 11 16:48 manifest.inc.php

Note that /var/www/piwik/config/config.ini.php is NOT present. Thanks again for your attention.

@mattab commented on July 13th 2016 Owner

Note that /var/www/piwik/config/config.ini.php is NOT present.

When config.ini.php is not present, this means that Piwik is not installed.

If someone is blocked from installing Piwik because of this bug, please let us know here, and ideally we will need FTP or SSH access to your piwik server for us to troubleshoot further (please email via: http://piwik.org/contact ). We'd like to fix this issue :+1:

@ZacharyDuBois commented on July 14th 2016

@mattab The issue does not block the installation. We are saying it is falsely identifying the setup. The page is indeed 500'ing for an uncaught exception that appears to be related to the fact the system is not configured (IE no config.ini.php). As soon as the installation finishes (Ignoring the 500 warning) the /piwik.php returns a standard 400 - bad method which is what it should do. The issue isn't a specific setup, the issue is the installer checks for /piwik.php wrong. Something in /piwik.php depends on the configuration file to exist and the check that just fetches the /piwik.php fails because of that dependency. The check is flawed and is non-configuration specific as I have just confirmed it on the following VMs with 'standard' setups.

  • Ubuntu 14.04 LTS Nginx + PHP7 (FPM) + MariaDB
  • Ubuntu 14.04 LTS Nginx + PHP5 (FPM) + MariaDB
  • Ubuntu 16.04 LTS Nginx + PHP7 (FPM) + MariaDB
  • Ubuntu 16.04 LTS Nginx + PHP5 (FPM) + MariaDB
  • Ubuntu 14.04 LTS Apache + PHP7 (Module) + MariaDB + HT-files enabled
  • Ubuntu 14.04 LTS Apache + PHP5 (Module) + MariaDB + HT-files enabled
  • Ubuntu 16.04 LTS Apache + PHP7 (Module) + MariaDB + HT-files enabled
  • Ubuntu 16.04 LTS Apache + PHP5 (Module) + MariaDB + HT-files enabled
@richb-hanover commented on July 14th 2016

Yes, ZacharyDuBois describes the situation exactly. I think it's a reporting problem - the "Server Check" page reports the 500 error. Consequently, I stopped and reported the message here.

(One time, I did decide to click Next. I was taken to the MySQL database setup page, but I decided not to proceed with the database until all previous steps complete without error.) Thanks again.

@tsteur commented on July 14th 2016 Owner

It shouldn't return the 500 error, I think we are either talking about 2 different problems or it's not clear. The tracker, even when it is not installed yet, should report an HTTP 200 AFAIK
image

This is a screenshot of when I am installing Piwik. And it reports tracker status correctly:

image

The tracker is supposed to ignore the config error and return an HTTP 200 if Piwik is not installed yet, meaning if config.ini.php is missing. It is not supposed to return HTTP 500 or 400. So there seems to be a problem somewhere and I was initially thinking it was detecting it maybe wrongly as being executed from CLI https://github.com/piwik/piwik/blob/2.16.1/core/Common.php#L129 where it was not executed from CLI but the web. Looking at the error message again it seems to actually detect it correctly that it was executed from the web. Otherwise the error message would be longer.

It is supposed to ignore the error here: https://github.com/piwik/piwik/blob/2.16.1/core/Application/Kernel/EnvironmentValidator.php#L65-L77 but somehow it is instead throwing the error. It means for some reason it is not detecting that it is running in Tracker mode which means there might be related to $GLOBALS (not "register_globals") but it shouldn't. Can someone in line 40 https://github.com/piwik/piwik/blob/2.16.1/core/SettingsServer.php#L38-L41 replace return !empty($GLOBALS['PIWIK_TRACKER_MODE']); with return true and check if it still reports an error?

@mattab commented on July 19th 2016 Owner

as we are planning to release 2.16.2 in the next few days, we would need to fix this issue soon for the fix to be in 2.16.2. If anyone is able to help us troubleshoot as per our previous comment here, it would be helpful!

@richb-hanover commented on July 19th 2016

@tsteur Replacing the line 40 as suggested (with "return true;") generates a different error:

An error occurred
The configuration file {/var/www/piwik/config/config.ini.php} has not been found or could not be read.

What other information could I provide? Thanks.

@mattab commented on July 21st 2016 Owner

Hello guys, Somehow the bug appeared on my dev machine, so I investigated it. The issue should be fixed in the latest 2.16.2-beta release 2.16.2-b4. Could you please test it and report whether it is fixed correctly?

@richb-hanover commented on July 21st 2016

Where would I find the beta download? Thanks.

@mattab commented on July 21st 2016 Owner

Here is the latest beta: http://builds.piwik.org/piwik-2.16.2-b5.zip

you can also easily upgrade to beta using the UI, see: http://piwik.org/faq/how-to-update/faq_159/

please test with at least 2.16.2-beta6

@richb-hanover commented on July 21st 2016

@mattab I just tried 2.16.5-beta5, and it was almost perfect.

  1. The installation was successful - I am getting statistics on my dashboard.
  2. .../piwik.php now gives the expected 200 status and "Piwik is a free/libre web analytics that lets you keep control of your data." page.
  3. But... I still get the 500 warning for Tracker Status (see image in original post).

TL;DR Piwik install works if you ignore the warning. But it still gives the (somewhat ominous) Tracker Status error in the second installation screen.

@mattab commented on July 21st 2016 Owner

@richb-hanover Thanks for trying. I managed to let a bug slip in beta5 which should be fixed in beta6 - maybe you have a chance to test beta6?

@richb-hanover commented on July 21st 2016

@mattab Would it be as simple as

  • rm -rf piwik
  • unzip b6
  • chmod/chgrp to www-data
  • re-running the install via the web?

Or would I have to drop tables from the database, etc.?

@mattab commented on July 21st 2016 Owner

@richb-hanover sounds good, you don't have to drop tables

@richb-hanover commented on July 22nd 2016

It worked a treat! Thanks for fixing this.
piwik2 16 2-b6 worked

This Issue was closed on July 21st 2016
Powered by GitHub Issue Mirror