Set Memory Limit for PHP CLI on RunCloud, OpenLiteSpeed

On a RunCloud instance, PHP CLI is a separate server setting which is a toggle control to set the version of PHP that applies to using PHP commands on the command line for the whole server. You can set it by selecting the server in the RunCloud panel then Settings > PHP-CLI Version > PHP Version

Php Cli Server Runcloud
PHP-CLI Version

The default memory for the PHP-CLI version is set at 128MB which in certain PHP commands/scripts will hit the fatal error out of memory usage and won’t complete the script, you can get around this by editing the php.ini file, currently there is no RunCloud panel setting for this so you’ll need to edit the file directly.

In the 2 values for memory, the PHP-CLI uses the master value and the webapp uses the local value:

Php Memory Limit
Taken from a phpinfo function for the site

The location of the php config files are version specific, so for example using PHP 8.1 it would be:

/usr/local/lsws/lsphp81/etc/php/8.1/litespeed

Change the path to the version you want to change. Then edit the php.ini file inside the directory, search for memory and change the memory_limit from 128MB to 256MB or more if needed.

memory_limit = 256M

Save the file and the memory limit is set.

Set PHP Version and memory limit on webapps

Setting memory limits and PHP versions is different for the web apps on the server than the PHP CLI settings and is web app specific. The PHP version is set under the:

Web Application > Settings > PHP Version

And the memory is set under:

Web Application > Settings > PHP Settings > memory_limit

Php Web Apps Version Memory
Set PHP Version for a web app
Php Memory Limit Setting
Set web app memory limit

That’s it, hopefully RunCloud will include the PHP-CLI memory setting via the panel in the future.

ref

Leave all Comment