This is an old revision of the document!


Prerequisites

LiteSpeed Web Server Enterprise Edition with Magento 2 should be set up and working already.

PHP

Magento 2 requires PHP versions 7.0.2+, 5.6.x, or 5.5.x. In the command line, type php -v to get the php version used by the command line interface. This version may be different than the one used by the server. If the version number does not match the one used within the server, there may be some compatibility issues.

Run the command which php to get the directory of the php binary. Then, change the current binary name to something different as a backup (e.g. mv php php-orig). Lastly, symbolic link or copy the binary installed in the LSWS directory to the directory returned by the which command. If the which command doesn't return anything, we recommend using /usr/local/bin/ or /usr/bin/.

Example using PHP 7 with which returning /usr/bin/php:

mv /usr/bin/php /usr/bin/php-orig
ln -s /usr/local/lsws/lsphp70/bin/php /usr/bin/php

Run php -v afterwards. If the steps were done correctly, the version number should match the server's php version.

Installation

The following steps assume that the Prerequisites mentioned above are met.

  1. Access a terminal as the Magento directory owner (e.g. “user1”) and cd to the Magento 2 root directory. If logged in as root, do su user1 first.
  2. If the current deploy mode is “default” instead of “production”, you could install litemage2 without changing it to “production”. If the current deploy mode is “production”, you have to set the store to “developer” mode before installation and change it back to production after the installation.
      php bin/magento deploy:mode:set developer
  3. There are two ways to get litemage2 packages:
  4. Confirm that the contents' owner is consistent with the other magento store files.
  5. Enable LiteMage 2 in magento:
    php bin/magento module:enable Litespeed_Litemage
  6. Upgrade the Magento setup:
    php bin/magento setup:upgrade
  7. Recompile using the signal tenant compiler or multi-tenant compiler. The single-tenant compiler has some issues. link.If you have one website and store, please run:
    php bin/magento setup:di:compile

    If you have multiple websites and stores, Please run:

    php bin/magento setup:di:compile-multi-tenant
  8. If desired, switch back to production mode. The previous step may need to be repeated after the mode switch.
    php bin/magento deploy:mode:set production
      

Note: For php 7.0.5 user, It may hit a bug which causing PHP Fatal error. The workaround is to delete var/di/relations.ser. It should not be problem with php 7.0.6 and above versions or non 7.x version.link

rm var/di/relations.ser

Enable LiteMage after Installation:

  1. In the Magento 2 root directory's .htaccess file, add the following lines:
    <IfModule LiteSpeed>
    LiteMage on
    </IfModule>
  2. Log into the Magento admin page.
  3. In Store → Configuration → Advanced → System, make sure LiteMage is enabled and the Full Page Cache setting has LiteMage selected.
  4. In System → Cache Management, refresh configurations and page cache.
  5. Visit and refresh a page that should be cache enabled. Look for the LiteMage related response headers.
    Example:
    X-LiteSpeed-Cache: hit,litemage

For related LiteSpeed Server setting configuration, please refer to: litespeed web server settings for litemage

Tips: For dedicated VPS/server, although it's not "have to", to gain better performance with LiteMage,
      please make sure Check Public Cache setting in server cache policy part is set to Yes.
  • Admin
  • Last modified: 2017/01/04 17:18
  • by Jackson Zhang