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

cron fatal error Undefined constant 'STDOUT' #61

Closed
bomakalu opened this issue Jul 5, 2017 · 23 comments
Closed

cron fatal error Undefined constant 'STDOUT' #61

bomakalu opened this issue Jul 5, 2017 · 23 comments

Comments

@bomakalu
Copy link

bomakalu commented Jul 5, 2017

Great work, This issue I am having is with the cron renewal: error:

PHP Fatal error: Undefined constant 'STDOUT' in /home/username/acme-client/vendor/league/climate/src/Util/Writer/StdOut.php on line 14

shared hosting using a cron job set up in cpanel. I cant seem to find an answer to this?

Any ideas thanks for your help:)

@kelunik
Copy link
Owner

kelunik commented Jul 5, 2017

Which PHP SAPI is this running on? What does var_dump(PHP_SAPI); report?

@bomakalu
Copy link
Author

bomakalu commented Jul 5, 2017

Hi there, As I am a newbie on this I am not having much luck finding these details.
I am sorry as your script worked beautifully installing the certs.
Is there a way of determining or"Which PHP SAPI is this running on? What does var_dump(PHP_SAPI);"
I cant seem to get anything to tell me from the cli.?

@kelunik
Copy link
Owner

kelunik commented Jul 5, 2017

You can just create a new test.php with the following contents and run it as cron and look at the output.

<?php

var_dump(PHP_SAPI);

@bomakalu
Copy link
Author

bomakalu commented Jul 5, 2017

hi there
i created the file and then ran it in my browser and got
string(9) "litespeed"
is this of use?
thanks again

@kelunik
Copy link
Owner

kelunik commented Jul 5, 2017

If you access it from a browser it's probably another PHP SAPI. You really need to run it just like you ran the original script that failed.

@bomakalu
Copy link
Author

bomakalu commented Jul 5, 2017

ok
When i create the cron from cpanel I am using this:

To renew certificate, customer can set up cron job as under every month :

php acme-client/bin/acme issue --domains domain.com:www.domain.com --path /home/username/public_html:/home/username/public_html --server letsencrypt

i created the test.php and then ran this as a cron:

/usr/local/bin/php /home/petehillman/public_html/test.php

i set it for everyminute but its not sending anything through or i am not seeing output?
thanks

@kelunik
Copy link
Owner

kelunik commented Jul 5, 2017

Maybe you only get the error output? Then try fputs(fopen("php://stderr"), PHP_SAPI);

@bomakalu
Copy link
Author

bomakalu commented Jul 5, 2017

Hi there
I a dont understand this you mean as replace the test.php with this code?
thanks

@bomakalu
Copy link
Author

bomakalu commented Jul 5, 2017

Ok heres the cron email i just got:

Status: 500 Internal Server Error
X-Powered-By: PHP/5.6.30
Content-type: text/html; charset=UTF-8

@kelunik
Copy link
Owner

kelunik commented Jul 5, 2017

I guess your cron just calls the webserver and runs it. Is your acme-client installation accessible via the web browser?

@bomakalu
Copy link
Author

bomakalu commented Jul 5, 2017

I cant access that location via the webbrowser.
it looks like the cron for some reason using cpanel wont run this from the correct
location. Is there a way to run this from the cli and create an auto renew?
thanks

@kelunik
Copy link
Owner

kelunik commented Jul 5, 2017

I don't know. Could you ask your hosting provider regarding that?

@bomakalu
Copy link
Author

bomakalu commented Jul 5, 2017

I have been on hold with them for almost a day. the issue i have is to just get it to renew on auto and there cron wont do it. what about manual renew is that simple?
thanks

@kelunik
Copy link
Owner

kelunik commented Jul 5, 2017

You can also simply run acme-client issue every month, but your hosting provider really should run the cron with php-cli instead of any other PHP SAPI.

@bomakalu
Copy link
Author

bomakalu commented Jul 5, 2017

This is great help I am very thankful spent a ,ot of head scratching as its a crapy server and they are as helpful as a dead cat. I will try it and get back to you. thanks for your help

@kelunik
Copy link
Owner

kelunik commented Jul 5, 2017

You could just add the following code at the beginning of bin/acme for now: https://stackoverflow.com/a/28898174/2373138

@bomakalu
Copy link
Author

bomakalu commented Jul 5, 2017

Hi there
brilliant
so when i added them i get this error via email:

Please run this script on the command line!
X-Powered-By: PHP/5.6.30
Content-type: text/html; charset=UTF-8

Does thsi mean anything?

thanks

@kelunik
Copy link
Owner

kelunik commented Jul 5, 2017

You can either remove the check or add your PHP_SAPI for now.

acme-client/bin/acme

Lines 78 to 81 in f4cabf7

if (!in_array(PHP_SAPI, ["cli", "phpdbg"], true)) {
$climate->error("Please run this script on the command line!");
exit(1);
}

@bomakalu
Copy link
Author

bomakalu commented Jul 6, 2017

Hello and thanks
Can you say more about this: "add your PHP_SAPI for now."
I appreciate your help
thanks again

@kelunik
Copy link
Owner

kelunik commented Jul 6, 2017

The thing you previously got from fputs(fopen("php://stderr"), PHP_SAPI);, but just remove the check.

@bomakalu
Copy link
Author

bomakalu commented Jul 6, 2017

Hi there I ran the issue at the command line and received this error:

selfVerify failed, please check http://www.petehillman.com/.well-known/acme-challenge/EoI-fBRTnai3OBQtw5_3j5LfHV__gN0_XdI4uMlxanM.
exception 'Kelunik\Acme\AcmeException' with message 'Issuance failed, not all challenges could be solved.' in /home/petehillman/acme-client/src/Commands/Issue.php:106

are you familiar with this?

thanks

@bomakalu
Copy link
Author

bomakalu commented Jul 6, 2017

I see from another thread "I had the same problem, it drove me nuts for a whole day. Turned out I had set up .htaccess to allow access only from my IP. Don't know if this is issue in your case, but it's one thing you might check. I don't know what IP is acme-client using, but looking at logs I see that now it was 66.133.109.36."

I can see I will continue to get this error. Do you know of a way to allow the acme-client access via the htaccess file.
thanks mate its a head scratcher

@kelunik
Copy link
Owner

kelunik commented Jul 6, 2017

You need to allow public access, not only for acme-client, as the CA (Let's Encrypt) needs access, too.

@kelunik kelunik closed this as completed Sep 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants