omega8cc / boa

Barracuda Octopus Aegir 5.4.0
https://omega8.cc/compare
394 stars 75 forks source link

php memory limit not changing #1281

Open Corvalan opened 6 years ago

Corvalan commented 6 years ago

I need to increase the php memory limit because composer complains it needs more.

in /opt/etc/fpm/fpm-pool-common.conf I have set php_admin_value[memory_limit] to 2G

then i reloaded service php56-fpm reload which is the only fpm service running as far as i see. I even rebooted the server.

Still the php memory limit shows as 1028M when i use php -r "echo ini_get('memory_limit').PHP_EOL;"

What could i have missed here?

Corvalan commented 6 years ago

It appears that the php memory setting used in my boa system is /opt/etc/php56/lib/php.ini

fpm-pool-common.conf skips that file?

omega8cc commented 6 years ago

BOA is using separate settings and INI files for PHP CLI and FPM. Furthermore, every Octopus instance has these limits enforced via account level PHP ini file in /home/o1.web/.drush/. The same is valid for your SFTP/SSH account o1.ftp. They are auto-configured depending on the RAM available.

But you mentioned composer, so you are probably looking to increase CLI limits only?

Please be more specific and confirm which exactly account you are using where you wish to change these limits, so we could confirm where you can adjust them.

Corvalan commented 6 years ago

I´m using account o1.ftp with composer commands. Composer is the only reason why I am forced to increase php memory limit. My server uses 16GB RAM.

omega8cc commented 6 years ago

For global system PHP-CLI you should edit the correct PHP version file located in one of these paths:

/opt/php56/etc/php56.ini /opt/php70/etc/php70.ini

For o1.ftp the file to edit is /home/o1.ftp/.drush/php.ini

Note that you will need to make it editable first (as root) with command:

chattr -i -R /home/o1.ftp/.drush

You may need to edit all these INI files, since composer may invoke global PHP default versions and not your Aegir PHP-CLI version.

gandhiano commented 5 years ago

I am facing a similar problem. I attempted to increase the memory both at the global level (/opt/php56/etc/php56.ini), as well as for the o1 user I'm running PHP from (/data/disk/o1/.drush/php.ini) but there is no change in the assigned memory:

$ php -r "echo ini_get('memory_limit').PHP_EOL;"
512M
gandhiano commented 5 years ago

I found now the right place to do this setting for composer to work. It is under /opt/php56/lib/php.ini (of course in my case for PHP version number 5.6, replace with the appropriate version in use).

This should probably be added to the documentation, as I guess anyone using composer to update drupal 8 sites on a host with a limited amount of RAM will face this problem.

yaazkal commented 5 years ago

Hi, not sure why composer is requiring that on a production server, maybe you are doing composer update or similar task on the server? maybe also developing directly on the server? (Nothing wrong if that is a dev server).

But, It is always recommended and a better practice to run something like composer update, composer require, composer remove or any other resource consuming command on a local/dev machine, then push the composer.lock file to the server and run composer install --no-dev in production (--no-dev because we will not need developtment dependencies on production, right?).

I hope that helps both of you to have a better workflow and a healthy server.

lexsoft00 commented 5 years ago

You could add a file composer_nolimit and add this command to it. Make it an executable and whitelisted to be accessible by o1.ftp. php -d memory_limit=-1 /usr/local/bin/composer

Then instead of calling composer you can call composer_nolimit, or you can increase the limit there.

Hope this helps.

lexsoft00 commented 5 years ago

Hi @Corvalan

I've written a solution here: https://github.com/omega8cc/boa/issues/1308#issuecomment-443180525