Php Limit DirectAdmin

We can increase php limit, and set it up permanently, so that system update cannot reset the limit.

Locate the Php version path in the system;


/usr/local/phpXX

Suppose, you got the path is /usr/local/php74

So, your php.ini file path will be /usr/local/php74/lib/php.ini

But you should not edit the  /usr/local/php74/lib/php.ini file directly, because it will be replaced by any future update !

Edit a custom file so that it not get overwritten with update,

/usr/local/php74/lib/php.conf.d/90-custom.ini


Set Php limit;


nano /usr/local/php74/lib/php.conf.d/90-custom.ini

Add the following limits to the file

max_execution_time = 300
max_input_time = -1
max_input_vars = 30000
memory_limit = 512M
post_max_size = 500M
upload_max_filesize = 1024M


If you have multi php version, then set up the custom php.ini for all version.


Additionally, Set modifiable limit ranges that user can customize;

cp /usr/local/directadmin/data/templates/php_settings.json /usr/local/directadmin/data/templates/custom/php_settings.json

nano /usr/local/directadmin/data/templates/custom/php_settings.json




Set php-fpm setting;


Example instance: 4 core, 8 gb ram, 240 gb space


pm = dynamic
pm.max_children = 40 ; Depends on your server's memory and the memory usage of each PHP process.
                     ; A general calculation: (Total RAM - for Operating System) / Average PHP process memory.
                     ; If each PHP process takes 100MB of memory, then about 70-80 processes can run on 8GB of RAM.
                     ; 40-50 processes is a good number to start with.
pm.start_servers = 10
pm.min_spare_servers = 5
pm.max_spare_servers = 15
pm.max_requests = 500 ; Each child process will restart after handling 500 requests.
                      ; This helps to avoid memory leaks.


Finally configure the global php-fpm customization;

nano /usr/local/directadmin/data/templates/custom/php-fpm.conf.custom1



pm = dynamic
pm.max_children = 40
pm.start_servers = 10
pm.min_spare_servers = 5
pm.max_spare_servers = 15




Save and exit the file.


reboot

da build all




########################################

CloudLinux Php Selector;


If you use the CloudLinux, then the php.ini path is different !

Set the Global php limit for alt-php;

nano /etc/cl.selector/global_php.ini

Add the following settings to the bottom of the file;

max_execution_time = 300
max_input_time = -1
max_input_vars = 30000
memory_limit = 768M
post_max_size = 512M
upload_max_filesize = 384M


Additionally, Set modifiable limit ranges that user can customize;

nano /etc/cl.selector/php.conf

Then re-build the PHP-Selector with reinstall command;

yum reinstall lvemanager cagefs alt-python27-cllib

cagefsctl -r



Then reboot the server

Post a Comment