PHP-FPM configuration

Hi, I am new to virtualmin.

I have 4 core and 4gb ram Virtualmin GPL server with around 30-40 websites 30-40 but not much traffics.
However, my ram is always full and it keeps on shutting down mysql database.

After some research, I have changed my apache configuration in /etc/httpd/conf.d/z-optimize.conf to

ServerLimit 150 StartServers 4 MinSpareThreads 25 MaxSpareThreads 75 ThreadLimit 64 ThreadsPerChild 25 MaxRequestWorkers 150 MaxConnectionsPerChild 1000

My php-fpm configuration in /etc/php-fpm.d/www.conf to

pm = dynamic
pm.max_children = 100
pm.start_servers = 16
pm.min_spare_servers = 8

However, i don’t think that www.conf is working as the php-fpm seems to be over 100 process sometimes. So, I am considering whether to change each pool config file in /etc/php-fpm.d/ but there are too many pools that i think will takes a lot of times so I am asking here see what you guys opinion.

It’s fine now. I have learnt more on php-fpm pool and understand that each virtual server need their own pool for security reason. So, changing www.conf did nothing to me, I need to change each individual pool config. ( Before that, I thought that having a config file at the end would actually overwrite all previous file)

Next, I have learnt how to add php-fpm configuration needed into existing virtual server by

  1. Adding those configuration into “Virtualmin > System Settings > Server Templates > Default Settings > PHP Options > Additional FPM pool options”.
  2. Change all the existing “virtual server > Server Configuration > Website Option > PHP Execution Script” from fpm to fcigd , then from fcigd back to fpm for the addition fpm configuration to be added into existing server.
    I do this using virtualmin command line instead of doing it manually.

Can refer to this node