This is an old revision of the document!
LiteMage for Magento 2 Installation Guide
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.
- 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. - 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
- There are two ways to get litemage2 packages:
- Method 1: Using composer to get latest litemage2 package
composer require litespeed/module-litemage
or
composer require litespeed/module-litemage:2.0.4
It will get litemage2 latest package or specified version from https://packagist.org/packages/litespeed/module-litemage and install to vendor/litespeed. It will need your username(public key) and password(private key) authentication for repo.magento.com. Apply one if you don't have it. Please check here for details: http://devdocs.magento.com/guides/v2.0/install-gde/prereq/connect-auth.html
- Method 2: Download litemage2 package directly.
- Download the zip package file from this repository: https://github.com/litespeedtech/magento2-LiteSpeed_LiteMage/archive/master.zip.
- Unzip the source package. The unzipped directory should be named magento2-LiteSpeed_LiteMage-master.
- In the Magento 2 root directory, run the following command to create the needed directories
mkdir -p app/code/Litespeed/Litemage
- Move the contents from the GitHub directory to the newly created directory:
mv /path/to/magento2-LiteSpeed_LiteMage-master/* app/code/Litespeed/Litemage/
- Confirm that the contents' owner is consistent with the other magento store files.
- Enable LiteMage 2 in magento:
php bin/magento module:enable Litespeed_Litemage
- Upgrade the Magento setup:
php bin/magento setup:upgrade
- 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
- 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:
- In the Magento 2 root directory's .htaccess file, add the following lines:
<IfModule LiteSpeed> LiteMage on </IfModule>
- Log into the Magento admin page.
- In Store → Configuration → Advanced → System, make sure LiteMage is enabled and the Full Page Cache setting has LiteMage selected.
- In System → Cache Management, refresh configurations and page cache.
- 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.