Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. {code}
  2. export PHP_FCGI_MAX_REQUESTS = 200
  3. export PHP_FCGI_MAX_CHILDREN = 1
  4.  
  5. php -b localhost:9000 &
  6. php -b localhost:9001 &
  7. php -b localhost:9002 &
  8. php -b localhost:9003 &
  9. php -b localhost:9004 &
  10. {code}
  11.  
  12. - We now have 5 php instances running, each will last for 200 requests before dying (to prevent memory leaks), and each instance is on its own port.
  13.  
  14. This is how mod_fastcgi and mod_fcgid (to my knowledge) spawn php instances.
  15. This DOES NOT SUPPORT APC.
  16.  
  17.  
  18.  
  19. {code}
  20. export PHP_FCGI_MAX_REQUESTS = 1000
  21. export PHP_FCGI_MAX_CHILDREN = 5
  22.  
  23. php -b localhost:9000 &
  24. {code}
  25.  
  26. - We now have 6 php instances running, 1 master and 5 child processes. Each will last for 200 requests before dying (to prevent memory leaks), but only the master process has a port, it handles sending requests to the children that actually handle the requests.
  27.  
  28. Because of this master/child setup, APC can work (the master keeps a cache, that all the children can share)
  29.  
  30. This is how php-fpm and lighttpd's spawn-fcgid work. (usually used with alternative webservers.)
  31.  
  32.  
  33.  
  34.  
  35. While both of these code blocks will work to start a php fastcgi server without any tools like php-fpm or such, they are NOT for use in production. You need a process manager that will automatically restart PHP when it ends (when it hits the max request limit.)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement