Custom php.ini cron jobs don´t work

joaosavioli

Well-Known Member
Feb 7, 2008
67
11
58
Hi,

I´m trying to use a custom php.ini for cron jobs, but php ignore my php.ini and use global settings.
[email protected] [~]# /opt/cpanel/ea-php56/root/usr/bin/php -c php.ini -i | grep memory_limit
memory_limit => 256M => 256M

[email protected] [~]# cat php.ini
; cPanel-generated php ini directives, do not edit
; Manual editing of this file may result in unexpected behavior.
; To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
; For more information, read our documentation (PHP Home - EasyApache 4 - cPanel Documentation)

allow_url_fopen = Off
allow_url_include = Off
asp_tags = Off
display_errors = Off
enable_dl = Off
file_uploads = On
max_execution_time = 90
max_input_time = -1
max_input_vars = 1000
memory_limit = 512M
session.gc_maxlifetime = 1440
session.save_path = "/var/cpanel/php/sessions/ea-php56"
upload_max_filesize = 10M
always_populate_raw_post_data = -1

I´ve tried to add in master php.ini (/opt/cpanel/ea-php56/root/etc/php.ini) these lines bellow, but I can see effect only in http.

[PATH=/home/user]
memory_limit = 512M;

I´m using mod_suphp.

Could you help me?

Thank you.
João
 

JacobPerkins

Well-Known Member
May 2, 2014
617
97
103
cPanel Access Level
DataCenter Provider
Twitter
Hi,

Try copying your php.ini to a .user.ini, or make the changes via the cPanel >> INI Editor UI. Doing so should write the .user.ini out and it should work after that. Please let me know how it goes!
 

joaosavioli

Well-Known Member
Feb 7, 2008
67
11
58
Hi,

Try copying your php.ini to a .user.ini, or make the changes via the cPanel >> INI Editor UI. Doing so should write the .user.ini out and it should work after that. Please let me know how it goes!
Thank you for reply.

I've tried, but didn´t work.

[email protected] [~]# cat .user.ini
; cPanel-generated php ini directives, do not edit
; Manual editing of this file may result in unexpected behavior.
; To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
; For more information, read our documentation (PHP Home - EasyApache 4 - cPanel Documentation)

PHP:
asp_tags = Off
display_errors = Off
max_execution_time = 90
max_input_time = -1
max_input_vars = 1000
memory_limit = 1024M
session.gc_maxlifetime = 1440
session.save_path = "/var/cpanel/php/sessions/ea-php56"
upload_max_filesize = 10M
always_populate_raw_post_data = -1

/opt/cpanel/ea-php56/root/usr/bin/php -c php.ini -i | grep memory_limit
memory_limit => 256M => 256M

/opt/cpanel/ea-php56/root/usr/bin/php -i | grep memory_limit
memory_limit => 256M => 256M

/opt/cpanel/ea-php56/root/usr/bin/php -c .user.ini -i | grep memory_limit
memory_limit => 256M => 256M


Any idea?

Thank you
Joao
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,904
2,218
463
Hello,

Would you mind opening a support ticket using the link in my signature so we can take a closer look at the affected system?

Thank you.
 

joaosavioli

Well-Known Member
Feb 7, 2008
67
11
58
Hello,

I´ve opened a suport ticket and the problem was fixed.
Here is the solution to help comunity:

"Hello,

Usually if you need to set a Custom php.ini it is better to not use MultiPHPini Editor in WHM because it will create a file that overrides PHP settings.

# /opt/cpanel/ea-php56/root/etc/php.d/local.ini ( This file overrides custom php.ini files. )

I've moved this file out of the way for you to test the issue a bit further. Did you have a specific cron task that you were using where the issue was experienced? CLI PHP and CGI PHP can function differently sometimes. User accounts have a wrapper enabled which should auto determine their PHP version however if you call it from the full path to PHP it may result in something different occurring as well.

# /usr/local/bin/php ( wrapper )
# /opt/cpanel/ea-php56/root/usr/bin/php ( full path to script )

Calling PHP with the wrapper should automatically find the correct PHP version for this account. Curious if you were only testing with calling PHP directly or if you were actually using the PHP wrapper which is called automatically when you use command "php".

Best Regards,

--
Steven V. Sublett"

Thank you
Joao
 
  • Like
Reactions: cPanelMichael