Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
litespeed_wiki:php:enable_opcode_cache [2018/09/14 15:47]
Michael Alegre [For Shared Hosting Environments:PHP SuEXEC]
litespeed_wiki:php:enable_opcode_cache [2019/05/17 21:18] (current)
Kacey Schroeder [For Shared Hosting Environments: PHP SuEXEC]
Line 9: Line 9:
 ===== How to Enable Opcode Cache for LiteSpeed ===== ===== How to Enable Opcode Cache for LiteSpeed =====
  
-Opcode cache can be easily installed through yum or apt-get. To see if it has been enabled, check the corresponding phpinfo page. If you use the PHP non-EXEC mode you may be finished at this point, however when using PHP SuEXEC mode for shared hosting environments such as cPanel or Plesk, you also have to choose the right LSPHP SuEXEC ​mode. +Opcode cache can be easily installed through yum or apt-get. To see if it has been enabled, check the corresponding phpinfo page. If you use the PHP non-EXEC mode you may be finished at this point, however when using PHP SuEXEC mode for shared hosting environments such as cPanel or Plesk, you also have to choose the right PHP process ​mode. 
  
-==== For Shared Hosting Environments:​PHP SuEXEC ====+==== For Shared Hosting Environments:​ PHP SuEXEC ====
  
-For shared hosting environments such as cPanel or Plesk, you should use PHP SuEXEC mode as your execution method. ​LSWS Web Admin -> Server ​-> General ​-> Using Apache Configuration File -> PHP suEXEC ​-> Yes. When you check a user's phpinfo page, it may show that Zend Opcode Cache is installed and enabled. ​+For shared hosting environments such as cPanel or Plesk, you should use PHP SuEXEC mode as your execution method. ​**Configuration ​> Server > General > Using Apache Configuration File > PHP suEXEC** to ''​Yes''​. When you check a user's phpinfo page, it may show that Zend Opcode Cache is installed and enabled. ​
 However there are also three PHP process modes for LiteSpeed: Worker mode, Daemon mode and ProcessGroup mode.  However there are also three PHP process modes for LiteSpeed: Worker mode, Daemon mode and ProcessGroup mode. 
  
Line 35: Line 35:
  
 === ProcessGroup Mode vs. PHP-FPM === === ProcessGroup Mode vs. PHP-FPM ===
-Process Group Mode is similar to Apache php-fpm mode. The difference is: with Apache, the parent process of php-fpm is not controlled by Apache, and it keeps running; with LiteSpeed, LiteSpeed uses LSAPI, and the PHP will exit if idle for a while (in a shared hosting environment and set at [[https://​www.litespeedtech.com/​docs/​webserver/​config/​extapps/​lsapi#​extMaxIdleTime|"​Max Idle time"​]]). ​ For LSWS 5.2.8 and lower versions, PHP processes will stop when LSWS restarts, and the opcode cache will be reset. Starting from LSWS 5.3RC2 and above, LSPHP will run in detached mode and an LSWS restart //​won'​t//​ stop PHP processes. The LSPHP parent will just follow the timeout where [[https://​www.litespeedtech.com/​docs/​webserver/​config/​extapps/​lsapi#​extMaxIdleTime|"​Max Idle time"​]] is set.+ 
 +ProcessGroup ​Mode is similar to Apache php-fpm mode. The difference is: with Apache, the parent process of php-fpm is not controlled by Apache, and it keeps running; with LiteSpeed, LiteSpeed uses LSAPI, and the PHP will exit if idle for a while (in a shared hosting environment and set at [[https://​www.litespeedtech.com/​docs/​webserver/​config/​extapps/​lsapi#​extMaxIdleTime|"​Max Idle time"​]]). ​ For LSWS 5.2.8 and lower versions, PHP processes will stop when LSWS restarts, and the opcode cache will be reset. Starting from LSWS 5.3RC2 and above, LSPHP will run in detached mode and an LSWS restart //​won'​t//​ stop PHP processes. The LSPHP parent will just follow the timeout where [[https://​www.litespeedtech.com/​docs/​webserver/​config/​extapps/​lsapi#​extMaxIdleTime|"​Max Idle time"​]] is set.
  
 Please keep in mind that keep idle PHP process running longer will occupy server resources and there is a risk to overload the server if there is not enough resources. ​ Please keep in mind that keep idle PHP process running longer will occupy server resources and there is a risk to overload the server if there is not enough resources. ​
  
 === Sharing Opcode Cache Between Multiple CPU Processes === === Sharing Opcode Cache Between Multiple CPU Processes ===
-For LSWS 2CPU and above licenses, you have an option to [[litespeed_wiki:​cpanel:​multi-litespeed-processes|configure LSWS to use multi CPU cores]]. For LSWS 5.2.x and below, When a domain is served by multi-CPU cores, Opcode cache cannot be shared between CPU cores. ​ So, when you test a ''​phpinfo.php''​ page, you might see cache hits like the following upon refresh:+For LSWS Web Host Professional ​and above licenses, you have an option to [[litespeed_wiki:​cpanel:​multi-litespeed-processes|configure LSWS to use multi CPU cores]]. For LSWS 5.2.x and below, When a domain is served by multi-CPU cores, Opcode cache cannot be shared between CPU cores. ​ So, when you test a ''​phpinfo.php''​ page, you might see cache hits like the following upon refresh:
  
   http://​example.com/​phpinfo.php   http://​example.com/​phpinfo.php
Line 54: Line 55:
 As of LiteSpeed Web Server v5.3RC2 and above, LSWS //can share opcache between Multi CPU processes//​. As of LiteSpeed Web Server v5.3RC2 and above, LSWS //can share opcache between Multi CPU processes//​.
  
-==== For Non-Shared Hosting Environments:​PHP non-SuEXEC ====+==== For Non-Shared Hosting Environments:​ PHP non-SuEXEC ====
  
 Non-shared hosting environments should use PHP non-exec mode. (**LSWS Web Admin > Server > General > Using Apache Configuration File > PHP suEXEC** = ''​No''​). LSPHP just runs in ''​workgroup''​ mode as the "​nobody"​ user by default. For this situation, as long as you see opcode cache in the phpinfo page, opcode cache has already been enabled. Non-shared hosting environments should use PHP non-exec mode. (**LSWS Web Admin > Server > General > Using Apache Configuration File > PHP suEXEC** = ''​No''​). LSPHP just runs in ''​workgroup''​ mode as the "​nobody"​ user by default. For this situation, as long as you see opcode cache in the phpinfo page, opcode cache has already been enabled.
  • Admin
  • Last modified: 2018/09/14 15:47
  • by Michael Alegre