Actions

Help

Difference between revisions of "Install:Quick Install Magento"

From OpenLiteSpeed Wiki

m (Updated Installation link.)
 
(44 intermediate revisions by 3 users not shown)
Line 1: Line 1:
After you download and install OpenLiteSpeed, follow the instructions below to get your WordPress site working.
+
After [[Help:Installation_Guides|downloading and installing OpenLiteSpeed]], follow the instructions below to get your Magento site working. The installation process for Magento 1.x and Magento 2.0 are slightly different, so please ensure that you are following that steps for the the version you wish to install.
 +
 
 +
 
 
__TOC__
 
__TOC__
<p><b>1. RPM install</b></p>
 
<p>yum install curl-devel libmcrypt-devel</p>
 
<p><br></p>
 
<p><b>2. Build PHP</b> (5.3.24, for example)</p>
 
<p>Admin Console =&gt; Actions =&gt; Compile PHP</p>
 
<p>'--with-mysqli' '--with-zlib' '--with-gd' '--enable-shmop' '--enable-track-vars' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-magic-quotes' '--enable-mbstring' '--with-iconv' '--with-mysql' '--with-libdir=lib64' '--with-litespeed' '--with-mcrypt' '--with-curl' '--with-pdo' '--with-pdo-mysql'</p>
 
<p>Note: '--with-libdir=lib64' is for x86_64 systems.</p>
 
<p><br></p>
 
<p><b>3. Download and unpack Magento into /usr/local/lsws/DEFAULT/html/magento</b> (This is a subdirectory of the vhost "Example".)</p>
 
<p>cd /usr/local/lsws/DEFAULT/html</p>
 
<p>wget http://www.magentocommerce.com/downloads/assets/1.7.0.2/magento-1.7.0.2.tar.gz</p>
 
<p>tar -zxvf </p>
 
<p><br></p>
 
<p><b>4. Change ownership of all files in the Magento directory so that the web server has write permission during installation</b></p>
 
<p>chown -R nobody /usr/local/lsws/DEFAULT/html/magento</p>
 
<p><br></p>
 
<p><b>5. Set up Magento on a vhost</b> (Here we use the default virtual host "Example")</p>
 
<p>Admin Console =&gt; Configuration =&gt; Virtual Hosts =&gt; Example =&gt; General =&gt; Index Files </p>
 
<p>Add "index.php"</p>
 
<p><br></p>
 
<p><b>6. Set up a MySQL database for Magento</b></p>
 
<p>The Magento site does not have instructions for this, but a good example can be found on the WordPress site: http://codex.wordpress.org/Installing_WordPress#Detailed_Instructions</p>
 
<p><br></p>
 
<p><b>7. Add the following rewrite rules in your virtual host settings</b> (WebAdmin Console =&gt; Virtual Hosts =&gt; Example =&gt; Rewrite =&gt; Rewrite Rules) to make Magento work</p>
 
<p>Note: These rewrite rules are taken directly from the official Magento site. Any questions about them would be best directed to Magento forums. These rules are also written for installation in the subdirectory "magento". If you are  installing in the docroot, remove "magento" from the rules containing it (such as "RewriteBase /magento ==&gt; RewriteBase /", "RewriteRule .* /magento/index.php [L]</p>
 
<p> =&gt; RewriteRule .* /index.php [L]")</p>
 
<p><br></p>
 
<p>============&gt;8============</p>
 
<p>    RewriteBase /magento</p>
 
<p><br></p>
 
<p>############################################</p>
 
<p>## Uncomment out the next line to enable light API calls processing</p>
 
<p><br></p>
 
<p>#    RewriteRule ^/api/([a-z][0-9a-z_]+)/?$ api.php?type=$1 [QSA,L]</p>
 
<p><br></p>
 
<p>############################################</p>
 
<p>## Rewrite API2 calls to api.php (by now it is REST only)</p>
 
<p><br></p>
 
<p>    RewriteRule ^/api/rest api.php?type=rest [QSA,L]</p>
 
<p><br></p>
 
<p>############################################</p>
 
<p>## Workaround for HTTP authorization in the CGI environment</p>
 
<p><br></p>
 
<p>    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]</p>
 
<p><br></p>
 
<p>############################################</p>
 
<p>## TRACE and TRACK HTTP methods disabled to prevent XSS attacks</p>
 
<p><br></p>
 
<p>    RewriteCond %{REQUEST_METHOD} ^TRAC[EK]</p>
 
<p>    RewriteRule .* - [L,R=405]</p>
 
<p><br></p>
 
<p>############################################</p>
 
<p>## Redirect for mobile user agents</p>
 
<p><br></p>
 
<p>    #RewriteCond %{REQUEST_URI} !^/mobiledirectoryhere/.*$</p>
 
<p>    #RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]</p>
 
<p>    #RewriteRule ^(.*)$ /mobiledirectoryhere/ [L,R=302]</p>
 
<p><br></p>
 
<p>############################################</p>
 
<p>## Always send 404 for missing files in these folders</p>
 
<p><br></p>
 
<p>    RewriteCond %{REQUEST_URI} !^/magento/(media|skin|js)/</p>
 
<p><br></p>
 
<p>############################################</p>
 
<p>## Never rewrite for existing files, directories, and links</p>
 
<p><br></p>
 
<p>    RewriteCond %{REQUEST_FILENAME} !-f</p>
 
<p>    RewriteCond %{REQUEST_FILENAME} !-d</p>
 
<p>    RewriteCond %{REQUEST_FILENAME} !-l</p>
 
<p><br></p>
 
<p>############################################</p>
 
<p>## Rewrite everything else to index.php</p>
 
<p><br></p>
 
<p>    RewriteRule .* /magento/index.php [L]</p>
 
<p><br></p>
 
<p>============&gt;8============</p>
 
<p><br></p>
 
<p><b>8. Graceful restart so the changes will take effect</b> (Actions =&gt; Graceful Restart)</p>
 
<p><br></p>
 
<p><b>9. Point your browser to http://server_ip:8088/magento and follow the instructions in the set up wizard</b></p>
 
  
[[Category:Help]]
+
== Install PHP Modules ==
 +
 
 +
The easiest way to install PHP for OpenLiteSpeed is through our CentOS repository. If the LiteSpeed Repository was not already installed and enabled during web server installation, follow [http://www.litespeedtech.com/support/wiki/doku.php?id=litespeed_wiki:php:rpm this guide] to do so.
 +
 
 +
Use the following command to install PHP with the required modules:
 +
 
 +
<blockquote><pre>yum install lsphp56 lsphp56-common lsphp56-gd lsphp56-process lsphp56-mbstring lsphp56-mysql lsphp56-mcrypt lsphp56-pdo lsphp56-xml lsphp56-intl</pre></blockquote>
 +
 
 +
:: '''Note:''' There are different versions of LSPHP (lsphp53, lsphp54, lsphp55, lsphp56, lsphp70, lsphp71) available. Please check your Magento version for PHP requirements.
 +
 
 +
 
 +
[http://www.litespeedtech.com/support/wiki/doku.php?id=litespeed_wiki:php:rpm#direct_lsws_to_the_location_of_the_installed_php Direct LSWS to the location of the installed PHP binary.] (In this example, PHP 5.6 is installed by default in <code>/usr/local/lsws/lsphp56/bin/lsphp</code>. In the WebAdmin Console, change the value of the '''External App > your_external_application > Command''' setting to reflect the PHP version you are using.)
 +
 
 +
If you are not using RedHat or CentOS, or you prefer to build PHP manually, see our instructions on [[Help:Building PHP for Magento| Building PHP for Magento]].
 +
 
 +
'''Magento 2:'''  You will need to set the value of "'''always_populate_raw_post_data'''" to '''-1''' in the related php.ini file. In this example, this file would be <code>/usr/local/lsws/lsphp56/etc/php.ini</code>. You should also make any memory configuration changes here if your version of Magento requires it.
 +
 
 +
''For Example:'' 
 +
    memory_limit = 768M
 +
    max_execution_time = 18000
 +
    session.auto_start = 0
 +
 
 +
== Set Up Magento On A Vhost ==
 +
Using the default "Example" virtual host:
 +
 
 +
# In the WebAdmin Console, navigate to '''Configuration > Virtual Hosts > Example > General > Index Files'''.
 +
# Add "index.php".
 +
 
 +
== Set up a MySQL database for Magento ==
 +
Start by installing MySQL:
 +
 
 +
<blockquote><code>yum install mysql mysql-server</code></blockquote>
 +
 
 +
'''Magento 2:''' You will need mysql 5.6 or later. [https://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/ More information on installing MySQL 5.6 from a repo]
 +
 
 +
 
 +
Next start MySQL, log into your MySQL server, and create a Magento database instance.
 +
 
 +
service mysql start
 +
 +
mysql -u root -p
 +
 +
#Enter the following commands while logged in to MySQL.
 +
 +
mysql>create database magento;
 +
mysql>GRANT ALL ON magento.* TO 'magento'@'localhost' IDENTIFIED BY 'magento';
 +
mysql>flush privileges;
 +
 
 +
http://devdocs.magento.com/guides/m1x/install/installing_install.html#install-create-db
 +
 
 +
== Magento 1 Installation ==
 +
=== Download Magento 1 ===
 +
# Register or log in to [https://account.magento.com/customer/account/login/ Magento.com].
 +
# [https://magento.com/tech-resources/download Download Magento from their release archive].
 +
# copy/ftp the downloaded files into your server's document root. Magento should be put in a subdirectory of the virtual host. For example, <code>/usr/local/lsws/Example/html/magento</code>. (This puts all the files in the right directory for running Magento on the default "Example" virtual host.)
 +
# Using Magento 1.9.3.1 as an example, uncompress the downloaded files with the following command: <code>tar -zxvf magento-1.9.3.1.tar.gz</code>
 +
 
 +
=== Change Ownership Of All Files In The Magento Directory ===
 +
In order for the web server to have write permissions during installation, ownership of the uncompressed Magento Files must be changed to the "nobody" user. Using the default "Example" virtual host, do so with the following command: 
 +
 
 +
<code>chown -R nobody /usr/local/lsws/Example/html/magento</code>
 +
 
 +
=== Add The Required Rewrite Rules To Your Virtual Host Settings ===
 +
Using the default "Example" virtual host:
 +
 
 +
# In the  WebAdmin Console, navigate to '''Virtual Hosts > Example > Rewrite'''.
 +
# Set '''Enable Rewrite''' to '''Yes'''.
 +
# Add the following to the '''Rewrite Rules''' setting:
 +
 
 +
<blockquote><pre>============>8============
 +
    RewriteBase /magento
 +
 
 +
############################################
 +
## Uncomment out the next line to enable light API calls processing
 +
 
 +
#    RewriteRule ^/api/([a-z][0-9a-z_]+)/?$ api.php?type=$1 [QSA,L]
 +
 
 +
############################################
 +
## Rewrite API2 calls to api.php (by now it is REST only)
 +
 
 +
    RewriteRule ^/api/rest api.php?type=rest [QSA,L]
 +
 
 +
############################################
 +
## Workaround for HTTP authorization in the CGI environment
 +
 
 +
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
 +
 
 +
############################################
 +
## TRACE and TRACK HTTP methods disabled to prevent XSS attacks
 +
 
 +
    RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
 +
    RewriteRule .* - [L,R=405]
 +
 
 +
############################################
 +
## Redirect for mobile user agents
 +
 
 +
    #RewriteCond %{REQUEST_URI} !^/mobiledirectoryhere/.*$
 +
    #RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
 +
    #RewriteRule ^(.*)$ /mobiledirectoryhere/ [L,R=302]
 +
 
 +
############################################
 +
## Always send 404 for missing files in these folders
 +
 
 +
    RewriteCond %{REQUEST_URI} !^/magento/(media|skin|js)/
 +
 
 +
############################################
 +
## Never rewrite for existing files, directories, and links
 +
 
 +
    RewriteCond %{REQUEST_FILENAME} !-f
 +
    RewriteCond %{REQUEST_FILENAME} !-d
 +
    RewriteCond %{REQUEST_FILENAME} !-l
 +
 
 +
############################################
 +
## Rewrite everything else to index.php
 +
 
 +
    RewriteRule .* /magento/index.php [L]
 +
 
 +
============>8============</pre></blockquote>
 +
 
 +
'''IMPORTANT :''' These rules are written for installations located in subdirectory "magento". If your Magento installation is located in the server docroot instead of the suggested <code>/magento</code> subdirectory, remove "magento" from the rewrite rules containing it. For example, <code>RewriteBase /magento</code> would become <code>RewriteBase /</code>, and <code>RewriteRule .* /magento/index.php [L]</code> would become <code>RewriteRule .* /index.php [L]</code>.
 +
 
 +
'''Note:''' These rewrite rules are taken directly from Magento's official site. Any questions regarding these rules would be best directed to the [https://community.magento.com/ Official Magento Forums].
 +
 
 +
=== Perform A Graceful Restart ===
 +
To make the previous server changes take affect, we must perform a graceful restart. In the WebAdmin Console, navigate to '''Actions > Graceful Restart'''.
 +
 
 +
=== Run The Magento Setup Wizard ===
 +
In your browser, visit http://your_server_ip:8088/magento and follow the instructions.
 +
 
 +
== Magento 2 Installation ==
 +
The following instruction will walk you through installing a basic Magento 2 site on OpenLiteSpeed. If you would like more in depth information on installing and configuring Magento 2, please refer to the [http://devdocs.magento.com/guides/v2.0/install-gde/install-flow-diagram.html Official Magento 2 Installation Guide].
 +
 
 +
The following commands should be run as the root user.
 +
 
 +
=== Install Composer ===
 +
Install composer with the following command:
 +
 
 +
<code>yum install composer</code>
 +
 
 +
=== Add The Correct PHP Path To The $Path Environment Variable ===
 +
By default, Composer will check for PHP at system default location - usually <code>/usr/bin/php</code>. This can sometimes cause Composer's version checking to fail. To avoid this, we will add our PHP installation directory the $PATH environment variable. Using LSPHP-56 as an example, run the following command:
 +
 
 +
<code>export PATH="/usr/local/lsws/lsphp56/bin/:$PATH"</code>
 +
 
 +
=== Choose An Installation Directory For Magento 2 ===
 +
Using the default "Example" virtual host, we create a directory for our Magento 2 installation and enter into it.
 +
 
 +
cd /usr/local/lsws/Example/html
 +
mkdir magento2
 +
cd magento2
 +
 
 +
=== Get The Magento Software ===
 +
Using Composer, we will now get the most recent Magento 2 package.
 +
 
 +
<code><nowiki>composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition .</nowiki></code>
 +
 
 +
 
 +
You will then be prompted to enter a username and password for repo.magento.com using your Magento authentication keys.
 +
 
 +
    Authentication required (repo.magento.com):
 +
      Username:
 +
      password:
 +
 
 +
If you have not done so already, [http://devdocs.magento.com/guides/v2.0/install-gde/prereq/connect-auth.html Get your authentication keys].
 +
 
 +
=== Change Ownership Of All Files In The Magento Directory ===
 +
In order for the web server to have write permissions during installation, ownership of the uncompressed Magento Files must be changed to the "nobody" user. Using the default "Example" virtual host, do so with the following command: 
 +
 
 +
<code>chown -R nobody /usr/local/lsws/Example/html/magento2</code>
 +
 
 +
=== Add The Required Rewrite Rules To Your Virtual Host Settings ===
 +
Using the default "Example" virtual host:
 +
 
 +
# In the  WebAdmin Console, navigate to '''Virtual Hosts > Example > Rewrite'''.
 +
# Set '''Enable Rewrite''' to '''Yes'''.
 +
# Add the following to the '''Rewrite Rules''' setting:
 +
 
 +
    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 <code>/magento2</code> subdirectory, remove "magento2" from the rewrite rules containing it. For example, <code>RewriteBase /magento2/</code> would become <code>RewriteBase /</code>, and <code>RewriteRule .* /magento2/index.php [L]</code> would become <code>RewriteRule .* /index.php [L]</code>.
 +
 
 +
'''Note:''' These rewrite rules are taken directly from Magento's official site. Any questions regarding these rules would be best directed to the [https://community.magento.com/ Official Magento Forums].
 +
 
 +
=== Perform A Graceful Restart ===
 +
To make the previous server changes take affect, we must perform a graceful restart. In the WebAdmin Console, navigate to '''Actions > Graceful Restart'''.
 +
 
 +
=== Run The Magento Setup Wizard ===
 +
In your browser, visit http://your_server_ip:8088/magento and follow the instructions.
 +
 
 +
=== Fix css Loading Issue For Magento 2 Frontend/Backend ===
 +
The last step is to fix a css loading issue present in new Magento 2 installations. Using the default "Example" virtual host and assuming your Magento 2 installation is located under the <code>/magento2</code> subdirectory, we can do this with the following set of commands:
 +
 
 +
cd /usr/local/lsws/Example/html/magento2/
 +
php bin/magento setup:static-content:deploy
 +
php bin/magento indexer:reindex
 +
rm -rf var/cache/*
 +
chown -R nobody:nobody .

Latest revision as of 16:10, 14 December 2017

After downloading and installing OpenLiteSpeed, follow the instructions below to get your Magento site working. The installation process for Magento 1.x and Magento 2.0 are slightly different, so please ensure that you are following that steps for the the version you wish to install.


Install PHP Modules

The easiest way to install PHP for OpenLiteSpeed is through our CentOS repository. If the LiteSpeed Repository was not already installed and enabled during web server installation, follow this guide to do so.

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

yum install lsphp56 lsphp56-common lsphp56-gd lsphp56-process lsphp56-mbstring lsphp56-mysql lsphp56-mcrypt lsphp56-pdo lsphp56-xml lsphp56-intl
Note: There are different versions of LSPHP (lsphp53, lsphp54, lsphp55, lsphp56, lsphp70, lsphp71) available. Please check your Magento version for PHP requirements.


Direct LSWS to the location of the installed PHP binary. (In this example, PHP 5.6 is installed by default in /usr/local/lsws/lsphp56/bin/lsphp. In the WebAdmin Console, change the value of the External App > your_external_application > Command setting to reflect the PHP version you are using.)

If you are not using RedHat or CentOS, or you prefer to build PHP manually, see our instructions on Building PHP for Magento.

Magento 2: You will need to set the value of "always_populate_raw_post_data" to -1 in the related php.ini file. In this example, this file would be /usr/local/lsws/lsphp56/etc/php.ini. You should also make any memory configuration changes here if your version of Magento requires it.

For Example:

   memory_limit = 768M
   max_execution_time = 18000
   session.auto_start = 0

Set Up Magento On A Vhost

Using the default "Example" virtual host:

  1. In the WebAdmin Console, navigate to Configuration > Virtual Hosts > Example > General > Index Files.
  2. Add "index.php".

Set up a MySQL database for Magento

Start by installing MySQL:

yum install mysql mysql-server

Magento 2: You will need mysql 5.6 or later. More information on installing MySQL 5.6 from a repo


Next start MySQL, log into your MySQL server, and create a Magento database instance.

service mysql start

mysql -u root -p

#Enter the following commands while logged in to MySQL.

mysql>create database magento;
mysql>GRANT ALL ON magento.* TO 'magento'@'localhost' IDENTIFIED BY 'magento';
mysql>flush privileges;

http://devdocs.magento.com/guides/m1x/install/installing_install.html#install-create-db

Magento 1 Installation

Download Magento 1

  1. Register or log in to Magento.com.
  2. Download Magento from their release archive.
  3. copy/ftp the downloaded files into your server's document root. Magento should be put in a subdirectory of the virtual host. For example, /usr/local/lsws/Example/html/magento. (This puts all the files in the right directory for running Magento on the default "Example" virtual host.)
  4. Using Magento 1.9.3.1 as an example, uncompress the downloaded files with the following command: tar -zxvf magento-1.9.3.1.tar.gz

Change Ownership Of All Files In The Magento Directory

In order for the web server to have write permissions during installation, ownership of the uncompressed Magento Files must be changed to the "nobody" user. Using the default "Example" virtual host, do so with the following command:

chown -R nobody /usr/local/lsws/Example/html/magento

Add The Required Rewrite Rules To Your Virtual Host Settings

Using the default "Example" virtual host:

  1. In the WebAdmin Console, navigate to Virtual Hosts > Example > Rewrite.
  2. Set Enable Rewrite to Yes.
  3. Add the following to the Rewrite Rules setting:
============>8============
    RewriteBase /magento

############################################
## Uncomment out the next line to enable light API calls processing

#    RewriteRule ^/api/([a-z][0-9a-z_]+)/?$ api.php?type=$1 [QSA,L]

############################################
## Rewrite API2 calls to api.php (by now it is REST only)

    RewriteRule ^/api/rest api.php?type=rest [QSA,L]

############################################
## Workaround for HTTP authorization in the CGI environment

    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

############################################
## TRACE and TRACK HTTP methods disabled to prevent XSS attacks

    RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
    RewriteRule .* - [L,R=405]

############################################
## Redirect for mobile user agents

    #RewriteCond %{REQUEST_URI} !^/mobiledirectoryhere/.*$
    #RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
    #RewriteRule ^(.*)$ /mobiledirectoryhere/ [L,R=302]

############################################
## Always send 404 for missing files in these folders

    RewriteCond %{REQUEST_URI} !^/magento/(media|skin|js)/

############################################
## Never rewrite for existing files, directories, and links

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l

############################################
## Rewrite everything else to index.php

    RewriteRule .* /magento/index.php [L]

============>8============

IMPORTANT : These rules are written for installations located in subdirectory "magento". If your Magento installation is located in the server docroot instead of the suggested /magento subdirectory, remove "magento" from the rewrite rules containing it. For example, RewriteBase /magento would become RewriteBase /, and RewriteRule .* /magento/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.

Perform A Graceful Restart

To make the previous server changes take affect, we must perform a graceful restart. In the WebAdmin Console, navigate to Actions > Graceful Restart.

Run The Magento Setup Wizard

In your browser, visit http://your_server_ip:8088/magento and follow the instructions.

Magento 2 Installation

The following instruction will walk you through installing a basic Magento 2 site on OpenLiteSpeed. If you would like more in depth information on installing and configuring Magento 2, please refer to the Official Magento 2 Installation Guide.

The following commands should be run as the root user.

Install Composer

Install composer with the following command:

yum install composer

Add The Correct PHP Path To The $Path Environment Variable

By default, Composer will check for PHP at system default location - usually /usr/bin/php. This can sometimes cause Composer's version checking to fail. To avoid this, we will add our PHP installation directory the $PATH environment variable. Using LSPHP-56 as an example, run the following command:

export PATH="/usr/local/lsws/lsphp56/bin/:$PATH"

Choose An Installation Directory For Magento 2

Using the default "Example" virtual host, we create a directory for our Magento 2 installation and enter into it.

cd /usr/local/lsws/Example/html
mkdir magento2
cd magento2

Get The Magento Software

Using Composer, we will now get the most recent Magento 2 package.

composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition .


You will then be prompted to enter a username and password for repo.magento.com using your Magento authentication keys.

   Authentication required (repo.magento.com):
     Username:
     password:

If you have not done so already, Get your authentication keys.

Change Ownership Of All Files In The Magento Directory

In order for the web server to have write permissions during installation, ownership of the uncompressed Magento Files must be changed to the "nobody" user. Using the default "Example" virtual host, do so with the following command:

chown -R nobody /usr/local/lsws/Example/html/magento2

Add The Required Rewrite Rules To Your Virtual Host Settings

Using the default "Example" virtual host:

  1. In the WebAdmin Console, navigate to Virtual Hosts > Example > Rewrite.
  2. Set Enable Rewrite to Yes.
  3. Add the following to the Rewrite Rules setting:
   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 /magento2 subdirectory, 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.

Perform A Graceful Restart

To make the previous server changes take affect, we must perform a graceful restart. In the WebAdmin Console, navigate to Actions > Graceful Restart.

Run The Magento Setup Wizard

In your browser, visit http://your_server_ip:8088/magento and follow the instructions.

Fix css Loading Issue For Magento 2 Frontend/Backend

The last step is to fix a css loading issue present in new Magento 2 installations. Using the default "Example" virtual host and assuming your Magento 2 installation is located under the /magento2 subdirectory, we can do this with the following set of commands:

cd /usr/local/lsws/Example/html/magento2/
php bin/magento setup:static-content:deploy
php bin/magento indexer:reindex
rm -rf var/cache/*
chown -R nobody:nobody .