1. Home
  2. Magento 2 Guides
  3. Install Magento 2

Install Magento 2

Magento 2 (M2) offers three separate ways to install a new site, depending on preference and the intent for the store.  The complete dev docs are here.  There are three ways to install it Magento 2:

  1. composer
  2. archive/web install
  3. clone the Magento 2 repository

Only options 1/2 apply to stores that will be going live and selling to customers.  Cloning the M2 repository directly is intended for contributing developers who want to add improvements to Magento 2.

Install via composer

Follow the steps below to install Magento 2.X from scratch completely. In our example, we are setting up a site using the domain mojotest.com. Before we can proceed with composer, a basic vhost needs to be configured.

Setup a vhost or website for Magento 2

If you have set up a vhost at MageMojo for Magento 2 before, you can skip this section. You can also contact support@magemojo.com/kb, and our support can set up a vhost completely for you (or install Magento 2). This section also assumes you have a domain pointed to your server here (see DNS Management), or you will be utilizing host file entries.

  1. We need a website to install Magento under. Open Mojo Host Manager and select the User your site will be under (Users from the left-hand nav menu then select a user)
  2. Under the Websites area, click the add one link
  3. A blank form will appear. Fill it out completely with the domain(s) you will be using.
  4. Select and name a web root using the folder icon. Here we have named the document root folder the same as the website for easy identification
  5. With the form completed, click the yellow Create button in the bottom right to create the website in Mojo Host Manager.
  6. After the initial website is saved, open the website again to view the configuration. Click the Advanced Tab. Set the PHP version to 70, the website type to Magento2. Leave Varnish disable for now
  7. Click Update to save the change. The website type loads a different vhost config specifically for Magento 2, and you definitely want to use PHP7 for maximum performance.
  8. Before Magento can be installed, a database and database user is needed.  Click Database from the left-hand nav menu.
  9. Click Add New Database
  10. Enter a name for your database, and click the Create button to save it. Remember the database name for later.
  11. Now we need a database user, click the User tab in the database section to open the Add User form
  12. Enter a user name.
  13. Set the hostname to localhost.  The hostname should always be localhost unless you will be connecting to MYSQL outside of the MageMojo network.
  14. Set or generate a password.
  15. Click Create to add the user.
  16. Add permissions by clicking the Database tab next to the User tab in the database section.
  17. Select the database you just created in Step 8
  18. To the right, a list of users will be viewable.  The colored dot indicates whether a user has privileges to the selected database.  You should see they are all currently red.  Click the user created in Step 13to expand the privileges list.
  19. Click the ALL PRIVILEGES bubble to give this user all rights to your database. In the screenshot below, the database user mojotest_user has been given all privileges to the mojotest_db
  20. Click Update to save your changes.
  21. Now we are ready to install Magento 2.

Get Magento 2 Marketplace Keys

Along with Magento 2, Magento has added the Magento Marketplace for module management which allows you to set keys as a developer for installing modules and Magento 2.  If you do not already have an account, you should create one at Magento’s website at https://www.magentocommerce.com/products/customer/account/login

Once you have an account log in and click the Connect tab, you should see a screen similar to the screenshot below.

Click Secure Keys if you have not already. If you have used this before, a separate key is advised for each install. The key can be saved locally for later use as you install modules from the Marketplace. Copy the public and private key fields or leave the window open for reference. Select Generate New if you need a new key. The composer install will request these keys.

Login to your MageMojo.com server and deploy

Log into your MageMojo server via SSH, if you are not familiar with SSH via our SSH Access section. Once logged in, navigate to the web root set up for Magento 2 (make sure to connect as the right user).  Once in the document or web root, run the following command:

You see a long list of downloads like this –

If you are on a new server or have multiple sites, some of which are not using PHP7, you may see an error related to the default PHP version being 5.4. To get around this, set an alias for the user hosting your Magento 2 site per the below example.

After a moment you will be prompted for your username and password. This is misleading, and this is NOT your magentocommerce.com username and password. Rather, the username is the public key from the marketplace, and the password is the private key. If you are doing a lot of Magento 2 installs, you could make a script to feed this information in or use echo as in this example. Substitute in your public and private key.

Numerous libraries will be retrieved and installed for you.  Once you are back at the command prompt, visit the domain you set your vhost for, you should see the Magento 2 install screen if composer worked properly.

If you do not see this screen, review your configuration and be sure you are in the right place when deploying Magento 2. Contact  support@magemojo.com/kb with any questions.

Complete Magento 2 Installation

Web Installation

Now you can complete the installation using the web wizard.  Another option, if you skip this section is to complete the installation via command-line.

  1. Click Agree and Setup Magento
  2. Before installation, Magento 2 runs a readiness check. It will analyze the file permissions, PHP version, MySQL version, and other requirements. This will ensure your installation completes successfully. Click Start Readiness Check. If the check is good, you will see this screen
  3. Click Next. Enter the database information, leaving the host as localhost. The table prefix is optional. Click Next when all the database information has been entered. 
  4. Like Magento 1, Magento 2 uses base URLs, and this is set by your store address. Unlike Magento 1, Magento 2 will auto-generate an admin path for you. Change this as needed. The Advanced Options can be left to default. Click Next.
  5. Set the currency and timezone (the locale settings) as preferred. Click Next
     
  6. Set an admin username and password. Then click Next
  7. Finalize the installation by clicking Install Now

  8. Magento 2 will install. Any errors will be output to the screen, but this is rare if you passed the readiness check. You will see the success screen if no errors are encountered.

Now Magento 2 is installed, and you can get working on your store! Choose the frontend or backend to view the site.A default Magento 2 install with no products/sample data shows this page on completion.

Command-line installation

The command line installation is much faster, but you still have to have all the relevant fields, though if you use default options, you only need a few of them. To proceed with the command line installation, after deploying the Magento 2 files from composer, go to the bin directory of the Magento 2 install.

You will see a file named magento; this file is used to execute various commands. You can make it executable or always run it prefaced by PHP.

If your default is not PHP7, run the install like this:

In the above snippet, Magento 2 is installed with bare bones options; nothing is changed from default. At a minimum, these nine arguments are required to install Magento 2. Run a command like the above, and it will output the installation process to your shell.

If you have specific requirements, you can add more arguments, and this is very useful for scripting out multiple deploys or Magento 2 installations. The full list of arguments is available at http://devdocs.magento.com/guides/v2.0/install-gde/install/cli/install-cli-install.html

The example command above does everything the web wizard did but in a single step.

Updated on July 22, 2017

Was this article helpful?

Related Articles