Memory limit for user

Hello!

I would need such a function. Which allows the user to get unique php memory.
Since hestia’s interface does not support it at the moment, I can somehow solve it so that users of certain storage locations do not use the default (256mb). php memory, but e.g. 512-1024 etc. So that it is not available to everyone?

Thanks.

Hi @raptor666,

Keep in mind that if you didn’t disable it, users can create a .user.ini file and override memory_limit.

Regarding your issue, I would create a new php template and will add the needed memory limit with directive php_admin_value. Using this method, users can’t override memory_limit using .user.ini files.

Something like this example:

Note: I will use php 8.2 template as a base, will add a memory limit of 512 MB and the template name will be 512M-PHP-8_2.tpl (you can replace 512M with the text you want but the rest must be the same or Hestia won’t use the template):

cd /usr/local/hestia/data/templates/web/php-fpm/
cp PHP-8_2.tpl 512M-PHP-8_2.tpl

Now edit 512M-PHP-8_2.tpl and add this line:

php_admin_value[memory_limit] = 512M

The file will look like this:

; origin-src: deb/php-fpm/multiphp.tpl
;#=========================================================================#
;# Default Web Domain Template                                             #
;# DO NOT MODIFY THIS FILE! CHANGES WILL BE LOST WHEN REBUILDING DOMAINS   #
;# https://hestiacp.com/docs/server-administration/web-templates.html      #
;#=========================================================================#

[%domain%]
listen = /run/php/php%backend_version%-fpm-%domain%.sock
listen.owner = %user%
listen.group = www-data
listen.mode = 0660

user = %user%
group = %user%

pm = ondemand
pm.max_children = 8
pm.max_requests = 4000
pm.process_idle_timeout = 10s
pm.status_path = /status

php_admin_value[upload_tmp_dir] = /home/%user%/tmp
php_admin_value[session.save_path] = /home/%user%/tmp
php_admin_value[open_basedir] = /home/%user%/.composer:/home/%user%/web/%domain%/public_html:/home/%user%/web/%domain%/private:/home/%user%/web/%domain%/public_shtml:/home/%user%/tmp:/tmp:/var/www/html:/bin:/usr/bin:/usr/local/bin:/usr/share:/opt
php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f admin@%domain%
php_admin_value[memory_limit] = 512M

env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /home/%user%/tmp
env[TMPDIR] = /home/%user%/tmp
env[TEMP] = /home/%user%/tmp

Now change the backend template for the web domain via Web UI or via command line:

v-change-web-domain-backend-tpl HereTheUser HereTheDomain 512M-PHP-8_2
1 Like

thanks! :slight_smile:

1 Like

Please note it is each process …