Koozali.org: home of the SME Server

Memory size using php71 at command level.

Offline brianr

  • *
  • 988
  • +2/-0
Memory size using php71 at command level.
« on: July 25, 2017, 12:11:17 PM »
I am running a rather heavy php program at the command prompt.  It runs fine under the default php (5.3.3), but when I run it under php71 (installing using the SCL contrib) it runs out of memory, giving me this:

PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in ....

where do I increase the memory allowed for php71?

Cheers Brian
Brian j Read
(retired, for a second time, still got 2 installations though)
The instrument I am playing is my favourite Melodeon.
.........

Offline Daniel B.

  • *
  • 1,699
  • +0/-0
    • Firewall Services, la sécurité des réseaux
Re: Memory size using php71 at command level.
« Reply #1 on: July 25, 2017, 12:32:24 PM »
php.ini is in /etc/opt/remi/php71/php.ini (which uses templates in Stéphane's contrib), but you can override it on the command line if needed:

Code: [Select]
php71 -dmemory_limit=512M /path/to/my_script.php
C'est la fin du monde !!! :lol:

Offline mmccarn

  • *
  • 2,626
  • +10/-0
Re: Memory size using php71 at command level.
« Reply #2 on: July 25, 2017, 12:36:30 PM »
PHP_Software_Collections#Usage implies that there is a db variable you use to set the MemoryLimit set for PHP71

Quote
[root@sme9b3dev64 ~]# config show php71
php71=configuration
   AllowUrlFopen=Off      #(On/Off)
   MaxExecutionTime=30
   MaxFileUpload=20
   MaxInputTime=60
   MemoryLimit=128M
   PhpModule=disabled    #(enabled/disabled)
   PostMaxSize=20M
   UploadMaxFilesize=10M

Offline brianr

  • *
  • 988
  • +2/-0
Re: Memory size using php71 at command level.
« Reply #3 on: July 25, 2017, 03:54:34 PM »
PHP_Software_Collections#Usage implies that there is a db variable you use to set the MemoryLimit set for PHP71

I'm not seeing the template for the php71 php.ini in /etc/e-smith/templates, is it somewhere else? or perhaps there is another action that translates the db variables into the php71 php.ini?
Brian j Read
(retired, for a second time, still got 2 installations though)
The instrument I am playing is my favourite Melodeon.
.........

Offline Daniel B.

  • *
  • 1,699
  • +0/-0
    • Firewall Services, la sécurité des réseaux
Re: Memory size using php71 at command level.
« Reply #4 on: July 25, 2017, 03:56:59 PM »
Looks like templates are in /etc/e-smith/templates/opt/remi/php71/root/etc/php.ini
C'est la fin du monde !!! :lol:

Offline brianr

  • *
  • 988
  • +2/-0
Re: Memory size using php71 at command level.
« Reply #5 on: July 25, 2017, 04:01:09 PM »
Looks like templates are in /etc/e-smith/templates/opt/remi/php71/root/etc/php.ini

so they are - thanks.
Brian j Read
(retired, for a second time, still got 2 installations though)
The instrument I am playing is my favourite Melodeon.
.........

Offline brianr

  • *
  • 988
  • +2/-0
Re: Memory size using php71 at command level.
« Reply #6 on: July 26, 2017, 01:07:58 PM »
for the record, here is how to change the memory_limit for php71:

# config setprop php71 MemoryLimit 1500M
# expand-template  /opt/remi/php71/root/etc/php.ini
# cat /etc/opt/remi/php71/php.ini | grep -i mem
memory_limit                           = 1500M
report_memleaks = On
Brian j Read
(retired, for a second time, still got 2 installations though)
The instrument I am playing is my favourite Melodeon.
.........

Offline Daniel B.

  • *
  • 1,699
  • +0/-0
    • Firewall Services, la sécurité des réseaux
Re: Memory size using php71 at command level.
« Reply #7 on: July 26, 2017, 03:32:28 PM »
This is only if you want to set this limit that high for everything. If you just need to rise the limit for a script, called from the command line, I still advise to set the override like this:

php71 -dmemory_limit=1500M /path/to/script.php

This way, standard PHP scripts ran by apache are still limited to a more reasonable value
C'est la fin du monde !!! :lol:

Offline brianr

  • *
  • 988
  • +2/-0
Re: Memory size using php71 at command level.
« Reply #8 on: July 26, 2017, 03:43:50 PM »
This is only if you want to set this limit that high for everything. If you just need to rise the limit for a script, called from the command line, I still advise to set the override like this:

php71 -dmemory_limit=1500M /path/to/script.php

This way, standard PHP scripts ran by apache are still limited to a more reasonable value

yes I can quite see that.
Brian j Read
(retired, for a second time, still got 2 installations though)
The instrument I am playing is my favourite Melodeon.
.........