3. Magento 2

< Back

Install: Quick Install Magento 2

After you install OpenLiteSpeed, follow the instructions below to get your Magemto 2 site working.

  1. Install PHP modules
  2. MariaDB Installation
  3. Create MagentoDB Account
  4. Set Index File and rewrite rules
  5. Download and Extract Magento
  6. Run the Magento install script

Install PHP Modules

The easiest way to install PHP for OpenLiteSpeed (without ols1clk) is through our CentOS repository. If the LiteSpeed Repository was not installed and enabled during the web server installation, follow this guide to install and enable the LiteSpeed Repository.

Step 1. Install PHP

Use the following command to install PHP with the modules required:

yum install lsphp70 lsphp70-mysqlnd lsphp70-common lsphp70-gd lsphp70-pdo lsphp70-process lsphp70-mbstring lsphp70-mcrypt lsphp70-opcache lsphp70-bcmath lsphp70-xml lsphp70-soap lsphp70-json lsphp70-intl -y

Note: There are multi versions of LSPHP (lsphp53, lsphp54, lsphp55, lsphp56, lsphp70, lsphp71, lsphp72) available.

Step 2. Set up PHP

Visit http://your_server_IP:7080. Navigate to Server Configuration > External app, then click the second icon Edit on the right hand side in order to edit this application.
Modify:
Name: lsphp → lsphp70
Address: uds://tmp/lshttpd/lsphp.sock → uds://tmp/lshttpd/lsphp70.sock
Command: $SERVER_ROOT/fcgi-bin/lsphp5 → $SERVER_ROOT/lsphp70/bin/lsphp

If you are not using RPM/APT, or you prefer to build PHP by yourself, see our instructions for building PHP here.

Step 3. Configure PHP

In this example, this file would be /usr/local/lsws/lsphp70/etc/php.ini. You should increase max_execution_timeand make any memory configuration changes here if your version of Magento requires it.

memory_limit = 768M
max_execution_time = 18000

Step 4. Restart LSWS

When you are finished, click the Save icon to save your changes, then click the Graceful Restart button.

Step 5. PHP Verification (Optional)

Visit http://your_server_IP:8088/phpinfo.php and make sure PHP Version shows 7.0.x.

MariaDB Installation

Install MariDB:

yum install mariadb-server
systemctl start mariadb

Set new password:

/usr/bin/mysql_secure_installation

Enter $yourpassword

Create magento DB Account

mysql -u root -p$yourmysqlpassword
create database magento; 
grant all privileges on magento.* to magento@localhost identified by 'magento'; 
exit;

Set Index File

An index file needs to be set in LiteSpeed Web Admin Console. Navigate to Virtual Hosts > Select Virtual Host from List > General > Index Files, click Edit in the top right corner, and enter index.html,index.php in the Index Files box.

Add a Rewrite Rule in the vhost to Make Permalinking Work

Go to the WebAdmin Console > Virtual Hosts > Example > General > Rewrite. Then change the following settings:

  • Enable Rewrite > Yes.
  • Rewrite Rules add
   RewriteRule ^/magento2/pub/static/version.+?/(.+)$ /magento2/pub/static/$1 [L]
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-l
   RewriteRule /magento2/pub/static/.* /magento2/pub/static.php?resource=$0 [L]
   RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
   RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
   RewriteRule .* - [L,R=405]
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_FILENAME} !-l
   RewriteRule .* /magento2/index.php [L]

IMPORTANT : These rules are written for installations located in subdirectory “magento2”. If your Magento installation is located in the server docroot instead of the suggested /magento2subdirectory, remove “magento2” from the rewrite rules containing it. For example, RewriteBase /magento2/ would become RewriteBase /, and RewriteRule .* /magento2/index.php [L] would become RewriteRule .* /index.php [L].

Note: These rewrite rules are taken directly from Magento’s official site. Any questions regarding these rules would be best directed to the Official Magento Forums.

Download and Extract Magento

To illustrate setting up Magento on a vhost we’ll use the default virtual host, “Example”. You can download Magento from their official download page. Please note that the document root of ‘Example’ virtual host is /usr/local/lsws/Example/html/. We will setup CE-2.2.4 with demo data version.

cd /usr/local/lsws/Example/html
mkdir magento2; cd magento2
### copy Magento-CE-2.2.4_sample_data.zip to here
unzip Magento-*.zip 

Grant the Web Server User Write Permission

chown -R nobody:nobody magento2

Graceful Restart

When you are finished, click the Save icon to save your changes, then click the Graceful Restart button.

Run the Magento Install Script

Step 1. Run Installation Script

Point your browser with default port to http://server_ip:8088/magento2/
Accept terms and conditions by clicking ‘Accept and Setup Magento’.

Step 2. Readiness Check

Magento CE installer needs to check if all the requirements are met, if you have followed all the guidelines above, all requirements should meet, just click ‘Start Readiness Check’.

 

Step 3. Set up Database

We’ve created the database above. Just enter the database details and click Save and continue. If the Magento installer is successfully able to connect to the database, it will start the installation process.

Enter database details we created above.

Step 4. Web Configuration

Setup your Store and Admin URL Path, e.g.

Step 5. Create Admin Account

On this step, the installer will let you configure settings for your site. Example settings are:

  • Site name: Litespeedtech
  • Site email address: magemto@example.com
  • Username: litespeedtech
  • Password: litespeedtech

Step 6. Install

Set Up Magento Caching (Optional)

Follow the steps described on this page to set up the LiteMage plugin