This is an old revision of the document!


How to enable PHP opcode cache for litespeed?

Since php 5.5, Zend Opcode cache has been included in php main packages distribution. You can easily install it through yum or apt-get. For php 5.4 and lower, you may choose APC cache. APC cache already include php opcode cache and user cache. To use user/variable cache for php 5.5 and up with zend opcode cache only, you may add apcu as addition.

For Xcache, it can be used upto php 5.6, but not 7.0.

You can install opcode cache through yum or apt-get easily. Check corresponding phpinfo page to see if it has been enabled. Don't think it is done at this point. It may be done when you use PHP non-EXEC mode, however when using PHP SuEXEC mode for shared hosting environment, such as cPanel or plesk, you have to choose right LSPHP SuEXEC mode.

For shared hosting environment:PHP SuEXEC

For shared hosting environment, such cpanel or plesk, you should use PHP SuEXEC mode. LSWS Web Admin → Server → General → Using Apache Configuration File → PHP suEXEC → Yes. When you check a phpinfo page for a user, it may have installed and enabled Zend opcode cache. However There are three PHP SuEXEC mode for LiteSpeed: suEXEC Worker Mode, suEXEC Daemon Mode and suEXEC ProcessGroup Mode. You may follow this wiki to check which SuEXEC mode you are using. suEXEC Daemon Mode and suEXEC ProcessGroup Mode support opcode cache while the default suEXEC Worker Mode does not. Please change to suEXEC Daemon Mode or suEXEC ProcessGroup Mode if required.

To set up suEXEC Daemon mode, you need only adjust your server-level LSPHP external application settings in the WebAdmin console > Configuration > External App > your LSPHP external application:

Set Auto Start to "Yes".
Set Run On Start Up to "suEXEC Daemon".

To setup ProcessGroup, you need to place the directive LSPHP_ProcessGroup in an httpd.conf file. This can be done at the server or virtual host level. If done at the server level, all virtual hosts will use ProcessGroup. If done at the virtual host level, only that virtual host will use ProcessGroup.

Example configuration:

<IfModule LiteSpeed>
LSPHP_ProcessGroup on
LSPHP_Workers 15
</IfModule>

For non-shared hosting environment:PHP non-SuEXEC

For non-shared hosting environment, you should use PHP non-exec mode. (LSWS Web Admin → Server → General → Using Apache Configuration File → PHP suEXEC → No). LSPHP just runs as workgroup mode as “nobody” user for default. For this situation, as long as you see opcode cache in phpinfo page, opcode cache has been enabled already.

Check details about PHP SuEXEC or non-SuEXEC here.

  • Admin
  • Last modified: 2016/06/17 19:27
  • by Jackson Zhang