Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ./console core:archive work on CGI (use case 1&1 hosting/managed server) #6012

Closed
wotis opened this issue Aug 16, 2014 · 11 comments
Closed
Assignees
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Milestone

Comments

@wotis
Copy link

wotis commented Aug 16, 2014

Since PIWIK 2.5 archiving and the archive cron only works with PHP-CLI.

But there are hosters out there, which do not offer PHP-CLI (e.g. 1&1 on manged servers). On those servers archiving stopped working with version 2.5 of PIWIK. You get the error:

Piwik Console is known to be not compatible with PHP-CGI (you are using cgi-fcgi). Please execute console using PHP-CLI. For instance "/usr/bin/php-cli console ..."

Archiving must be made possible to run with cgi-fcgi as it did in PIWIK versions before 2.5.

@HG1991
Copy link

HG1991 commented Aug 16, 2014

Yeah, i have the same Problem. Wondering why i doesent have even 1 Visitor today. Please fix this.

@mmessier
Copy link

I just ran into the same issues as of 8/15/2014 when Piwik updated to latest version (2.5.0). I was able to archive without
issue until today. This doesn't appear to be just one hosting company for I'm using GoDaddy.

I am also getting the following error:

Piwik Console is known to be not compatible with PHP-CGI (you are using cgi-fcgi). Please execute console using PHP-CLI. For instance "/usr/bin/php-cli console ..."

I am in hopes to assist in any way possible, though I am at a complete lose on why for the failure.

If anyone has any ideas in how to move forward, please "toss" some this way

Thanks

@meilon
Copy link

meilon commented Aug 16, 2014

Same problem here on Strato webservers (possibly the same boxes the 1&1 managed servers run on).

@tsteur
Copy link
Member

tsteur commented Aug 18, 2014

I'd recommend to try two options, they could work:

Web Archiving:
You can trigger the archiving via web using such an URL: http://yourdomain/yourpath/misc/cron/archive.php?token_auth=YOURAUTHTOKEN

In a cron you could do something like wget http://apache.piwik/misc/cron/archive.php?token_auth=dddddddddddddddddddddddddddddddd

archiver.php
Alternatively try to call the misc/cron/archiver.php this way:
php-cgi misc/cron/archive.php -- url=http://apache.piwik

and replace php-cgi with your PHP binary and --url=... with your domain.

@wotis
Copy link
Author

wotis commented Aug 18, 2014

@tsteur

Web Archiving
Does not work and throws out the same error message when I test it in a browser (»Piwik Console is known to be not compatible with PHP-CGI ...«)

archiver.php
This method still used to work with version 2.4 of PIWIK, but doesn't work anymore with PIWIK 2.5. With version 2.4 the archive.php brought the message »Error in argument 1, char 2: option not found r« for every website, but this had fortunately no effect on the archiving. With 2.5 it doesn't work and brings the well known error Piwik Console is known to be not compatible with PHP-CGI ...«

The only way archiving is possible at the moment is the manual way when calling the PIWIK backend.

@tsteur
Copy link
Member

tsteur commented Aug 18, 2014

Have you tried to run the archiver.php with a space after --? I tried it with php-cgi and it worked for me or did at least not show an error. In case it starts to archive but then later shows an error we can probably make it work by modifying this file: https://github.com/piwik/piwik/blob/master/core/CliMulti.php#L163 in line 163 as follows:

    public function supportsAsync()
    {
        return false;
    }

tsteur added a commit that referenced this issue Aug 18, 2014
…y that we will find a CGI php binary and we should fallback to use curl / web instead of executing a console command which does not support CGI. We would otherwise not detect whether the binary is CGI in case the php binary is named php54 etc. and not php54-cgi
@wotis
Copy link
Author

wotis commented Aug 18, 2014

With or without the space: it's not working and demands php-CLI

tsteur added a commit that referenced this issue Aug 19, 2014
…I. In type CGI the argv should not be registered anyway unless maybe for instance register-argc-argv is enabled
@tsteur
Copy link
Member

tsteur commented Aug 19, 2014

OK. As it worked for me using CGI I reckon your PHP registers argv variables so it still thinks it can use the console. Can you open misc/cron/archive.php and replace near the end of the file this:

if (isset($_SERVER['argv'])) {
    $console = new Piwik\Console();
    $console->init();

with this:

if (isset($_SERVER['argv']) && Piwik\Common::isPhpCliMode() && !Piwik\Common::isPhpCgiType()) {
    $console = new Piwik\Console();
    $console->init();

Also try to make the previous change in core/CliMulti.php if not done yet. It should work via Web and archive.php afterwards but I cannot tell for sure (because of different PHP settings, ...).

@wotis
Copy link
Author

wotis commented Aug 19, 2014

Great! It works!

After changing these two files archive.php works again as it did before 2.4/2.5 without any error messages.

Thank you! Will these changes make it into the next version of PIWIK?

@tsteur
Copy link
Member

tsteur commented Aug 19, 2014

sure. I'll close this issue now. In case it doesn't work for someone feel free to reopen

@tsteur tsteur closed this as completed Aug 19, 2014
@tsteur tsteur added Bug and removed Critical labels Aug 19, 2014
@tsteur tsteur added this to the Piwik 2.6.0 milestone Aug 19, 2014
@tsteur tsteur self-assigned this Aug 19, 2014
@mattab
Copy link
Member

mattab commented Aug 20, 2014

@tsteur nice fix Thomas! this will solve many user's trouble.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Projects
None yet
Development

No branches or pull requests

6 participants