User Tools

Site Tools


linux_server_manuals:apache_http_2_php-fpm

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
linux_server_manuals:apache_http_2_php-fpm [2018/09/07 14:38] adminlinux_server_manuals:apache_http_2_php-fpm [2021/08/18 14:46] (current) ronney
Line 11: Line 11:
 <code> <code>
 aptitude purge libapache2-mod-php aptitude purge libapache2-mod-php
 +
 </code> </code>
  
Line 21: Line 22:
 a2dismod mpm_prefork a2dismod mpm_prefork
 a2enmod mpm_event a2enmod mpm_event
 +
 </code> </code>
  
Line 27: Line 29:
 <code> <code>
 systemctl restart apache2 systemctl restart apache2
 +
 </code> </code>
  
 For further information, see [[https://wiki.apache.org/httpd/PHP-FPM|https://wiki.apache.org/httpd/PHP-FPM]] especially about ulimit and future issues if too many connection are opened. Take a look at the caveeats! Don't allow document upload into document root! Instead, let the application put uploads for example into /var/www/<appdir> . For further information, see [[https://wiki.apache.org/httpd/PHP-FPM|https://wiki.apache.org/httpd/PHP-FPM]] especially about ulimit and future issues if too many connection are opened. Take a look at the caveeats! Don't allow document upload into document root! Instead, let the application put uploads for example into /var/www/<appdir> .
 +
 +==== Increase pm.max_children ====
 +
 +PHP-fpm has a maximal amount of children processes which it uses to serve requests. The default setting of 5 most propably is too low for almost any kind of server. Check for similar messages in your log /var/log/php7.3-fpm.log<code>
 +
 +[05-Mar-2019 13:01:21] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 16 children, there are 3 idle, and 40 total children
 +[05-Mar-2019 13:01:22] WARNING: [pool www] server reached pm.max_children setting (50), consider raising it
 +
 +</code>
 +
 +To change it edit /etc/php/7.3/fpm/. The following values are no recommendations in any way. I've just copied it from a server, with relatively low load. You have to consider the expected amount of requests, but also your server resources, especially the memory.
 +
 +<code>
 +pm.max_children = 20
 +pm.start_servers = 5
 +pm.min_spare_servers = 1
 +pm.max_spare_servers = 5
 +
 +</code>
  
 ==== Increase PHP Execution Timeout ==== ==== Increase PHP Execution Timeout ====
Line 35: Line 57:
 If you use php scripts which run for a long time (>30s) then you need to change several settings, otherwise the script will timeout and the connection aborted. If you use php scripts which run for a long time (>30s) then you need to change several settings, otherwise the script will timeout and the connection aborted.
  
-To increase the php max execution time, change following line in the file /etc/php/7.0/fpm/php.ini+To increase the php max execution time, change following line in the file /etc/php/7.3/fpm/php.ini
  
 <code> <code>
 #Max time you want a script to be able to be running #Max time you want a script to be able to be running
 max_execution_time = 300 max_execution_time = 300
 +
 </code> </code>
  
Line 46: Line 69:
 <code> <code>
 [proxy_fcgi:error] [pid 11716:tid 140000557524736] (70007)The timeout specified has expired: [client 186.96.123.18:45986] AH01075: Error dispatching request to : (polling) [proxy_fcgi:error] [pid 11716:tid 140000557524736] (70007)The timeout specified has expired: [client 186.96.123.18:45986] AH01075: Error dispatching request to : (polling)
 +
 </code> </code>
  
Line 58: Line 82:
 # If you want to increase the timeout over 300, you also need to change that line # If you want to increase the timeout over 300, you also need to change that line
 Timeout 300 Timeout 300
 +
 </code> </code>
  
Line 66: Line 91:
 <code> <code>
 a2enmod http2 a2enmod http2
 +
 </code> </code>
  
-Create file /etc/apache2/mods-enabled/http2.conf+Create file /etc/apache2/mods-enabled/http2.conf (This is not necessary anymore with Debian 10 or newer)
  
 <file> <file>
Line 78: Line 104:
         H2Direct on         H2Direct on
 </IfModule> </IfModule>
 +
 </file> </file>
  
Line 90: Line 117:
     Require all granted     Require all granted
 </Directory> </Directory>
 +
 </code> </code>
  
  
linux_server_manuals/apache_http_2_php-fpm.1536331139.txt.gz · Last modified: 2018/09/07 14:38 by admin