eric-cs

Registered
Dec 21, 2020
2
0
1
Arlington Heights, IL
cPanel Access Level
Root Administrator
Is there a way in WHM or on the server to be able to set a different memory limit depending on if PHP is running from CLI vs FPM (web request)?
It looks like all of the config files are loaded the same whether you are running in CLI or not.

Thanks
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
7,519
1,028
313
cPanel Access Level
Root Administrator
Hey there! When you're on the command line and running PHP, it will use the system default. For example, I see this on a test machine where PHP 5.6 is the default for all accounts:

Code:
[email protected] [/]# which php
/usr/local/bin/php
[email protected] [/]# /usr/local/bin/php -v
PHP 5.6.40 (cli) (built: Nov  4 2020 10:02:45)
Since that is the case, the PHP limits for that version would be applied to command line processes as well. If you're not seeing that happening just let me know.
 

eric-cs

Registered
Dec 21, 2020
2
0
1
Arlington Heights, IL
cPanel Access Level
Root Administrator
Yes, but I want the CLI memory limit to be different than the PHP process running in FPM. Basically, I want unlimited memory limit for CLI processes since I am running some CLI tasks within Laravel which can be high memory usage.

It seems this isn't really supported or I just don't know how to be able to set them to be different values. Most default PHP installations on Linux usually allow for a different CLI ini config, but that doesn't seem to be the case for WHM/CPanel at least not out of the box or obvious to me.


Thanks
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
7,519
1,028
313
cPanel Access Level
Root Administrator
Thanks for the clarification. For the local script you're working with, could you add an "ini_set" value like this?

Code:
ini_set('memory_limit','512M')
That's the only thing I can recommend that may work, as there isn't a supported way to do that directly in PHP that I am aware of.