Actions

Help

Install:Quick Install Magento

From OpenLiteSpeed Wiki

Revision as of 22:04, 31 January 2017 by Jackson (talk | contribs) (Run the set up wizard)

After you download and install OpenLiteSpeed, follow the instructions below to get your Magento site working. Magento 1.x and Magento 2.0 's installation processes are slightly differenct. Please pay attention to the right version and right steps.

Install PHP modules

The easiest way to install PHP for OpenLiteSpeed 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.

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

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 requirment.

Direct LSWS to the location of the installed PHP. (In this example, PHP 5.6 is installed by default in /usr/local/lsws/lsphp56/bin/lsphp. Change the value of the WebAdmin console > External App > your external application > Command setting to reflect that.)

If you are not using RedHat or CentOS, or you prefer to build PHP by yourself, see our instructions for building PHP for Magento here.

Note: For Magento 2, you will need to change "always_populate_raw_post_data = -1" by modifying php.ini file locating at /usr/local/lsws/lsphp56/etc/php.ini. You may also make some memory config change if your version of magento requires, such as:
   memory_limit = 768M
   max_execution_time = 18000
   session.auto_start = 0

Set up Magento on a vhost

(Here we use the default virtual host "Example".)
Go to the WebAdmin Console > Configuration > Virtual Hosts > Example > General > Index Files.
Add "index.php".

Set up a MySQL database for Magento

First, install MySQL:
yum install mysql mysql-server
For Magento 2, you will need mysql 5.6 or later. You may need mysql 5.6 repo. The topic is beyond this wiki.
https://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/

then start mysql, log in to mysql server and create magento database instanace.

service mysql start
mysql -u root -p 
#Enter the remaining commands at the mysql> prompt.
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

Put Magento in a subdirectory of the virtual host /usr/local/lsws/DEFAULT/html/magento (This puts all the files in the right directory for running Magento on the virtual host "Example".)

Magento used to provide direct download link, such as

http://www.magentocommerce.com/downloads/assets/1.9.0.1/magento-1.9.0.1.tar.gz

but seems not anymore. you will need to register a user from https://magento.com/tech-resources/download and download from magento release archive, then ftp the file to your server document root location.

For example, you may download 1.9.3.1 from the above location and transfer the file to the following location:

cd /usr/local/lsws/DEFAULT/html
 tar -zxvf magento-1.9.3.1.tar.gz 

Change ownership of all files in the Magento directory so that the web server has write permission during installation

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

Add the following rewrite rules in your virtual host settings to make Magento work

Go to the WebAdmin console > Virtual Hosts > Example > Rewrite.
Enable Rewrite > Yes.
Rewrite Rules >
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 ==> RewriteBase /", "RewriteRule .* /magento/index.php [L] ==> RewriteRule .* /index.php [L]").
============>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============

Graceful restart

So the changes will take effect (Actions > Graceful Restart).

Run the set up wizard

Point your browser to http://server_ip:8088/magento and follow the instructions

Magento 2 Installation

The following command will run as root user. Please also refer Magento 2's installation guide.

Install composer

yum install composer

Add new php path to $PATH

Composer will check php at system default location such as /usr/bin/php, not installed location /usr/local/lsws/lsphp56/bin/php, which may cause composer version checking fail.
Add righ PHP path to $PATH env will fix the problem.
PATH=/usr/local/lsws/lsphp56/bin/:$PATH
export PATH

or

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

Choose the installation directory for Magento 2

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

Get magento software

composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition . 
It will prompt you to enter username and password for repo.magento.com.
   Authentication required (repo.magento.com):
     Username:
     password:
Request one if you have not done so.
http://devdocs.magento.com/guides/v2.0/install-gde/prereq/connect-auth.html

Change ownership of all files in the Magento directory so that the web server has write permission during installation

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

Add the following rewrite rules in your virtual host settings to make Magento work

Go to the WebAdmin console > Virtual Hosts > Example > Rewrite.
Enable Rewrite > Yes.
Rewrite Rules >
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 ==> RewriteBase /", "RewriteRule .* /magento/index.php [L] ==> RewriteRule .* /index.php [L]").
   Options +FollowSymLinks
   RewriteEngine on
   RewriteBase /magento2/
   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] 

Graceful restart

So the changes will take effect (Actions > Graceful Restart).

Run the set up wizard

Point your browser to http://server_ip:8088/magento2/ and follow the instructions

Fix css loading issue for Magento 2 frontend and backend

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 .