©  Viktor Khliupko 2017

Viktor Khliupko, Magento 2 DIY , 10.1007/978-1-4842-2460-1_4

4. Installation / Download

Viktor Khliupko

(1)Duesseldorf, Germany

A435230_1_En_4_Figa_HTML.jpg

In this chapter, we’ve gathered all the necessary information about Magento 2 installation. The new version of the platform has been finally released, so don’t hesitate to find out how to install the Magento 2 software. Below, we discuss different approaches to the Magento 2 installation from the use of the Setup Wizard to more complicated procedures based on Composer and the command line.

4 Types of Magento 2 Installation

Before starting our Magento 2 installation guide, we’d like to introduce you to four major approaches to this procedure. Below, you will find their descriptions as well as links to official guides. Magento 2 offers the ability to perform an easy installation and at the same time do everything to contribute code to its code base. Of course, each approach has unique requirements, so let’s begin with the easiest one.

Simple installation on your own server

Easy installation on your own server does not require any complicated tricks with the command line. You only need some technical expertise as well as command line access to your Magento server. This Magento 2 installation consists of the following steps:

  • Download a compressed file with the Magento software.

  • Then, you should extract it on your Magento server.

  • Now, install the software via the Setup Wizard. Alternatively, you can rely on the command line.

Simple installation on shared hosting

This approach to the Magento 2 installation is similar to the aforementioned one. The only difference here is in the usage of shared hosting. Get ready to find a hosting provider and perform a small technical expertise. You are already familiar with the installation steps:

  • Take a compressed file with the Magento software.

  • Extract it on the server.

  • Install the software via the Setup Wizard.

The metapackage

If you need a full control over all installed components of Magento 2, then this type of installation is for you. It is highly technical, provides access to your Magento server, and offers the ability to repackage Magento CE with other components. To install Magento 2 in such a way, do the following:

  • Create a new Composer project with the list of components you want to use.

  • Update your package dependencies via the same tool. Use the composer create-projectcommand to get the metapackage.

  • Now, you can install Magento 2 via the command line. The Setup Wizard can be utilized as well.

Cloning the Magento 2 repository

If you are a contributing developer who has a huge experience in using Composer and GitHub, then you might be interested in cloning the Magento 2 repo.

  • Clone the Magento 2 repository on GitHub.

  • Update package dependencies via Composer.

  • Install the software. Use either the Setup Wizard or the command line.

Now, when you know four major approaches to Magento 2 installation, we can go further.

Magento 2 Installation Guide

Magento 2 System Requirements

A435230_1_En_4_Figb_HTML.jpg

This is the set of system requirements for Magento 2:

  • Operating systems: Linux distributions (RHEL, Ubuntu, CentOS, Debian, etc.)

  • The latest stable version of Composer

  • Apache 2.2 or 2.4 (don’t forget to enable mod_rewrite module)

  • PHP: 5.4.x (x is 11 or above); 5.5.x

  • PHP extensions: PDO/MySQL, mcrypt, mbstring, mhash, curl, simplexml, gd2, ImageMagick 6.3.7, soap

  • MySQL 5.6.x

  • SMTP server of MTA

There are some optional but also very important recommendations: php_xdebug2.2.0 or above (development environments only); PHPUnit 4.1 or above as a tool for the command line.

Composer and Magento

To install the Magento software, you now need a Composer. It provides you with the ability to manage the system, extensions, and dependencies. The key features of Composer are:

  • It enables you to reuse third-party libraries with no need to bundle them with source code.

  • With Composer, you get a component-based architecture with a robust dependency management.

  • The tool manages dependencies; as a result you get much less compatibility issues and conflicts between extensions.

  • You also get versioned dependencies with Composer.

  • And don’t forget about Semantic versioning.

  • Last but not least is that Composer supports PHP Framework Interoperability standard.

More information is available in our Magento 2 Composer Guide1.

Composer Installation

  • Create a new and empty directory on a Magento server.

  • Enter the following:

1   curl -sS https://getcomposer.org/installer | php
2   mv composer.phar /usr/local/bin/composer

There are also some additional installation options, you can find them in Composer installation documentation.

  • Restart Apache: for Ubuntu use service apache2 restart; for CentOS use: service httpd restart

Magento GitHub Repository Cloning

  • It is extremely important to use secure shell (SSH ): generate SSH keys; add a public key to GitHub.

  • Copy the HTTPS clone URL or Magento GitHub repository SSH to the clipboard.

  • Open Magento GitHub repository in a browser.

  • Click SSH or HTTPS (under the “Clone URL” field on the right side).

  • Use “Copy to clipboard” button.

This is the example of HTTPS clone URL:

  • Change the docroot directory of web server: for Ubuntu, it’s /var/www; for CentOS - /var/www/html.

  • Use one of the following commands:

  • For HTTPS: git clone https://github.com/magento/magento2.git

  • For SSH: git clone [email protected]:magento/magento2.git

  • Now the repository will be cloned on a server.

File System Permissions & Ownership

The recommend settings for permissions are:

  • 700 permissions for all directories (drwx—-). The owner gets the full control—the ability to read/write/execute; other users have no permissions.

  • 600 permissions for all files (-rw—–). The owner is able to read and write, but nobody else gets the permissions.

Now, when the user of a web server owns the Magento 2 file system, you should use the following:

  • Use cd magento2 to change the Magento directory.

  • Use ps -ef | grep apache2 to find the web server user in Ubuntu; grep User /etc/httpd/conf/httpd.conf- in CentOS.

  • Use chown -R [your web server user name] to set ownership; in CentOS - chown -R apache; in Ubuntu - chown -R www-data.

    And finally you can set the permissions:

    1   find . -type d -exec chmod 700 {} ;
    2   find . -type f -exec chmod 600 {} ;

Installation Dependencies Update

Magento installation dependencies —Introduction

Magento relies on Composer for the first time, so before installing any Magento software, you must set up the Composer and perform the following:

  • First of all you have to Install the Composer.

  • Now you must Switch to the Apache user to let the Composer write files to the docroot of web server as the correct user.

  • From both of the below directories, run the composer install command:

1   <your Magento install dir>
2   <your Magento install dir>/setup

Keep in mind, that the main reason for failure is an incomplete or non-functional installation.

Switching to the Apache user:

For both Ubuntu and CentOS, avoid running Composer as the root user. And don’t forget that the user of web server on CentOS is apache; on Ubuntu - www-data.

Ubuntu

  • Enter su www-data.

    In case you don’t know the user’s password and a dedicated prompt appears, continue with the next step.

  • Use the following commands to enable the www-data user’s shell and to set a password:

    1   sudo chsh -s /bin/bash www-data
    2   sudo passwd www-data
  • Run su www-data again and enter the password.

  • To end the procedure, continue with Running Composer to update dependencies.

CentOS

  • Run su - apache. If “This account is currently not available” error displays, continue with the next step.

  • Use sudo chsh -s /bin/bash apache to give apache a valid shell account.

  • Enter su - apache again—it should work now.

Running Composer to update dependencies

  • Switch or log in as the web server user to the Magento server.

  • Change to the installation directory of Magento 2 - cd /var/www/html/magento2

  • Run composer install to update package dependencies.

Magento Software Installation With The Setup Wizard

Running the Setup Wizard

With the Setup Wizard, you can go back and forward through the pages of installation. You can’t skip pages, and you have to enter all the required information before you can go to the next step. It is possible to run the installer again or return to a previous page to fix errors.

Getting started

  • Open a web browser.

  • Enter http://[Magento host or IP]/[path to Magento root]/setup in the location or address bar. For the Magento server’s IP address “192.0.2.10” and magento2 directory, you should enter http://192.0.2.10/magento2/setup

  • Click Agree and Set Up Magento.

  • To complete the installation, continue with the following sections.

Step 1: Readiness Check

A435230_1_En_4_Figc_HTML.jpg
  • Use Start Readiness Check option.

  • Resolve all the problems if there are any before you go to the next step.

  • Use More detail to see the additional information about each check.

  • Click Next.

Step 2: Add a Database

A435230_1_En_4_Figd_HTML.jpg

Item

Description

Database Server Host

Enter localhost for the web and database servers located on the same host. For the database server from a different host, use its fully qualified IP address or hostname.

Database Server Username

Enter the username of the instance owner of Magento database.

Database Server Password

Enter the user’s password, if any or leave the blank field if you didn’t configure any password.

Database Name

Enter the instance name of Magento database.

Table prefix

You should use this field only if you’re installing the Magento database tables in a database instance with already existing Magento tables. To identify the Magento tables for this installation, use a prefix.

Step 3: Web Configuration

A435230_1_En_4_Fige_HTML.jpg

Item

Description

Your Store Address

Enter the URL of your storefront. It should include scheme and trailing slash (http://www.example.com/).

Magento Admin Address

Enter the URL of your Magento Admin.

Optionally, click Advanced Options and enter the following information:

Item

Description

HTTPS Options

To enable the use of SSL in the indicated URL, select the checkbox. Do this only if your web server supports SSL.

Apache Rewrites

Select this check box only if you enabled server rewrites while Apache installation.

Encryption Key

Magento can generate an encryption key. Use I want to use a Magento generated key option to receive it. If you have your own encryption key, you should use I want to use my own encryption key.

Step 4: Customize Your Store

A435230_1_En_4_Figf_HTML.jpg
  • Use Store Default Time Zone list to set the time zone of your store.

  • Use Store Default Currency list to choose the default currency.

  • Use Store Default Language list to choose the default language.

Step 5: Create Admin Account

A435230_1_En_4_Figg_HTML.jpg

Item

Description

New Username

Enter a username with which you will log in to the Admin of your Magento store. You will be an administrator and will be able to create other users and administrative users under this username.

New E-Mail

This is the field for e-mail address of Magento administrator.

New Password

The field for the password of administrator.

Confirm Password

Password confirmation field.

Step 6: Install

A435230_1_En_4_Figh_HTML.jpg

Click Install Now and you will get the following options:

  • By clicking Console Log, you will be able to see installation progress and error details.

  • By clicking Previous in the event of problems, you will be able to go back to fix incorrect entries.

  • By clicking Try Again, you will be able to run the installation again.

If the installation was successful, you will see the message Success.

Viewing the installation log

The Setup Wizard creates install.log, a log file, which can be useful for the debugging or in the actions verification. To locate the log, you should:

  • Use a text editor to open php.ini. If you don’t know where php.ini is located:

  • Switch to or log in as or the web server user.

  • In the docroot of your web server, create phpinfo.php.

  • Use a web browser to access phpinfo.php.

  • You can find the location of php.ini specified as Loaded Configuration File.

  • Find sys_temp_dir. Its value determines the location of install.log. PHP uses that value as its default in a case when the value is commented out. Keep in mind, that a typical default value is /tmp, so the log is /tmp/install.log.

Magento Software Installation From The Command Line

First steps

  • You should log in to the Magento server as the web server user or you can switch.

  • Change cd <your Magento install dir>/setup: cd /var/www/magento2/setup for Ubuntu and cd

  • /var/www/html/magento2/setup for CentOS

  • You can also use the following commands to find some values for required options: php -f index.php help language for Language; php -f index.php help timezone for Time zone and php -f index.php help currency for Currency.

Installing the Magento 2 software from the command line

Magento 2 Dev Beta—Installation with CLI.

The install command follows the next format:

1   php -f index.php install --[installation option name]=[installation option value]

Name

Value

Required?

base_url

Use Base URL to access your Magento Admin and storefront in the format http[s]://[host or ip]/[your Magento base dir]/. A scheme and a slash are required. [your Magento base dir] is the docroot-relative path, where the Magento software will be installed. It can be magento2 or might be blank. Use http://localhost/ [your Magento base dir]/ or http://127.0.0.1/ [your Magento base dir]/ to access Magento on localhost.

Yes

backend_frontname

This is the path to access the Magento Admin. It is is appended to Base URL. For the Base URL http://www.example.com and the Admin Pat admin, the Admin Panel’s URL would be is http://www.example.com/admin

Yes

db_host

You can use the database server’s fully qualified hostname, IP address, localhost if your database web servers are on the same host, or UNIX socket (/var/run/mysqld/mysqld.sock). In addition, there is an option to specify the database server port in its host name: www.example.com:9000

Yes

db_name

This is the name of the Magento database instance where you are going to install the Magento database tables.

Yes

db_user

Magento database instance owner’s username.

Yes

db_pass

The password of Magento database instance owner.

No

db_prefix

Use it if you have more than one Magento instance running on a server with all tables in the same database.

No

admin_firstname

First name of Magento administrator user.

Yes

admin_lastname

Last name of Magento administrator user.

Yes

admin_email

E-mail address of Magento administrator user.

Yes

admin_username

Username of Magento administrator.

Yes

admin_password

Password of Magento administrator user.

Yes

language

Language code for the Admin and storefront. To view the list of language codes enter php -f index.php help language from the setup directory.

Yes

currency

Default currency - php -f index.php help currency from the setup directory.

Yes

timezone

Default time zone - php -f index.php help time zone from the setup directory.

Yes

use_secure

1 enables the use of SSL in all URLs (your web server should support SSL). 0 disables the use of SSL.

No

base_secure_url

1 - SSL is preferred in Magento URLs. 0 - SSL is not used.

No

use_secure_admin

1 - SSL is used to access the Magento Admin.0 - SSL is not used with the Admin.

No

admin_use_security_key

1 - Magento software uses a randomly generated key value to access different pages in the Admin and forms. 0 disables the feature.

No

session_save

Use files to store session data in the file system; db.files—in the database.

No

key

Specify a key to encrypt data in the Magento database or Magento will generate its own.

No

cleanup_database

Specify this parameter without a value to drop database tables before Magento software installation, or the Magento database will be left intact.

No

db_init_statements

This is the advanced parameter for MySQL configuration. To set any values use this this link—you will find all the necessary information there.

No

sales_order_increment_prefix

Set a string value, which will be used as a prefix for sales orders. As a result, the payment processor will be provided with unique order number.

No

Sample localhost installation

As a result of such installation, your Magento receives the following options:

  • The software is installed in the magento2 directory. Your storefront URL - http://localhost/magento2; Magento Admin - http://localhost/magento2/admin;

  • The database and web server are on the same host.

  • The database name, username and password are magento.

  • The properties of Magento administrator includes:

  • Both first and last name are Magento User.

  • Username - admin, the password - iamtheadmin

  • E-mail address - [email protected]

  • The default language is U.S. English.

  • The currency is U.S. dollars.

  • The time zone is U.S. Central.

1   php -f index.php install --base_url=http://localhost/magento2/
2   --backend_frontname=admin
3   --db_host=localhost --db_name=magento --db_user=magento --db_pass=magento
4   --admin_firstname=Magento --admin_lastname=User [email protected]
5   --admin_username=admin --admin_password=iamtheadmin --language=en_US
6   --currency=USD --timezone=America/Chicago
  • Enter this command as a single line.

Reinstalling the Magento software

  • Delete and re-create the database instance (you can do it optionally).

  • Log in to your server as a user who has permission to modify files in the file system of Magento.

  • Run the following commands:

    1   cd <your Magento install dir>
    2   git pull
    3   composer install
    4   cd setup
    5   composer install
  • Repeat all the sections about Magento installation from the command line.

Magento 2 sample data

Now when you are logged as the Magento file system owner, you can install the Magento 2 sample data via the command line:

php <your Magento install dir>/bin/magento sampledata:deploy

Please note that it is necessary to authenticate to complete the action.

If you see the following authentication error

[ComposerDownloaderTransportException]

The ‘https://repo.magento.com/packages.json’ URL required authentication.

You must be using the interactive console to authenticate.

It is necessary to change to your Magento 2 installation directory and then run the following command:

composer update

Please note that it will prompt you for your authentication keys.

Magento 2 Setup Verification

Open a web browser and go to your storefront. If the browser displays the same storefront page, your installation was a success.

A435230_1_En_4_Figi_HTML.jpg

Verify the Magento 2 Admin

A435230_1_En_4_Figj_HTML.jpg

Use the same browser to open Magento 2 Admin, and log in as a Magento Administrator. If your Admin looks like a sample Magento 2 Admin page, then your installation was successfull.

How To Create A Virtual Machine For Magento 2

Since Magento 2 requires MySQL 5.6, there are a lot of problems with running Magento 2 in environments such as MAMP and XAMPP with MySQL 5.5 support only. If you are going to switch between Magento 1 and 2 projects, the issue can turn into a serious headache. Below, we’ve gathered information about solving the versions problem with the help of Magento 2 virtualization.

The traditional form of virtualization requires such software as VirtualBox on a host OS. A Virtual Machine (VM ) with its OS runs inside this software. The other form relies on Linux containers, which are used by Docker. They use Linux OS features like chroot to guarantee a set of processes in one “container.” With this form of virtualization, you don’t have to run a full new OS. Different containers are able to run different versions of software.

Vagrant is a special tool designed to create and configure development environments. Vagrant provides few ways of usage. Firstly, Magento 2 code base is checked out in the file system, whereupon the developer gets the ability to edit the code with the help of text editors. Secondly, the web browser is run right on the OS. Thirdly, the code resides in a Vagrant box. The content of the box doesn’t matter much to a developer, as long as the project works. In addition, you can easily share an environment definition with other developers and switch between different Magento projects —different boxes can be defined with different versions of the software. There is also no risk of conflict.

Magento 2 Vagrant Box

Magento 2 Vagrant Box 2 provides a simple way to get your Magento 2 project up and running. Based on a Debian Wheezy box provided via Puppet (VirtualBox is a provider), Magento2 Vagrant Box installs Apache 2 +FastCGI, PHP, PHP-FPM, MySQL and other dependencies. Being a git submodule, Magento 2 repository can be edited from the host machine. It is accessible via shared directories by the guest.

vagrant magento2 apache base

Get a dirty Vagrant image within minutes. With this Magento 2 tool3, you will be able to run MySQL and Apache in a Vagrant box and use other tools on a desktop. vagrant-magento2-apache-base relies on shell scripts to configure things. As a result, readers can poke around and you’ll get problems with learning such technologies as Puppet, Chef, or Ansible. The tool requires the latest version of VirtualBox and its Add-ons.

How to Install Magento 2 with Docker

Get your ticket to the world of containerization with Docker. In a situation where you are working with several projects, which run on different software versions (for example Magento 1.x on PHP 5.4, Magento 2.x on PHP 5.6, and web host on PHP 5.3) you probably face the problem when system packages don’t exactly match each other. Therefore, you can use Docker to simplify interactions with all your projects. This software solution allows you to package your apps with all their dependencies into standardized units (containers) designed for convenient software development, since they wrap up everything into a complete filesystem with runtime, code, system tools and libraries. As a result, a package runs the same in all possible environments. To get deeper insights into what is Docker, check this page4 on the official web site of the software. I also recommend you get acquainted with basic aspects of Magento development with Docker here5. Additionally, there is an important article on Magento 2 development with Docker on OS X6 on Mageinferno. Another important source of useful information related to Magento 2 and Docker is Alan Kent’s blog. For instance, he describes how to reduce install headaches with the aid of virtualization here7. Hit this link8 to get Docker on your computer.

PHP 7 Docker Image for Magento 2

The magento2-php9 image contains PHP configurations for Magento 2. Besides PHP 7, it also includes 5.6-fpm.

If you have any questions, check the official Magento 2 CE User Gide 10. The manual consists of three major parts: Contents, Introduction, and Basic Configuration. Although there is a Contents section on the first page of the Magento Community Edition 2.0 User Guide, there is also a dedicated section in the manual which provides more information by showing additional topics.

In its turn, the Introduction section describes available Magento resources, discusses the installation process, and shows how to access a Magento account. Besides, it sheds light on the main pages and key features of a Magento 2 web site. As for the Basic Configuration section, it introduces the Admin along with basic configuration settings and best practices. Besides, there is a “How To Use This Guide” section in a manual. Additionally, you can use its PDF version.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.205.154