Magento Setup And Installation

under Magento SEO.

Just getting started with Magento? This comprehensive guide will walk you through the full install process for both the Composer and compressed archive methods of installation, from system requirements to install verification. Once you're done, take a look at our other posts on configuring and working with Magento, as well as maximizing your SEO potential.

Let's dive in.

Server Requirements

apache http server project

Credit Apache.org

Before you get started, you need to make sure that your server meets the requirements needed to install Magento 2. You will need:

  • An Apache 2.2 or 2.4 server with mod_rewrite and mod_version modules enabled, OR nginx 1.x.
  • Linux x68-64, Magento is not supported on Windows or Mac OS.
  • At least 2GB of RAM if you want to run without a swap file and run Magento extensions reliably
  • A MySQL 5.6 or 5.7 database
  • PHP. Magento is certified and tested on PHP 7.2.11. PHP 7.1.3 and 7.2.0 are compatible. See Magento's documentation for PHP setup instructions and for additional information about which PHP extensions you will need. Enable PHP OPcache and use these settings.
  • SSL with a valid security certificate. Self-signed SSL is not supported, and TLS 1.1 or later is required for repo.magento.com. See Magento's TLS documentation for repo.magento.com. PayPal requires TLS 1.2. See Magento's documentation on PayPal TLS.
  • Magento requires access to these system tools:
  • A Mail Transfer Agent (MTA) or SMTP server for email
  • Magento Commerce requires three master databases
  • php_xdebug 2.5.x or later is recommended (for development environments only)
  • mcrypt is recommended
  • The command line tool PHPUnit 6.2.0 is recommended

Supported browsers for both the storefront and the admin include:

  • Internet Explorer 11 or later, Microsoft Edge, latest-1
  • Firefox latest, latest-1 (any operating system)
  • Chrome latest, latest-1 (any operating system)
  • Safari latest, latest-1 (Mac OS only)
  • Safari Mobile for iPad 2, iPad Mini, iPad with Retina Display (iOS 7 or later), for desktop storefront
  • Safari Mobile for iPhone 4 or later; iOS 7 or later, for mobile storefront
  • Chrome for mobile latest-1 (Android 4 or later) for mobile storefront

Create A Magento File System Owner

magento file system owner

Credit Navaneeth M

The Magento file system owner is a user with permissions to write files into the Magento file system. It is sometimes called the command-line user.

How you set permissions will depend on whether you are using shared hosting or a private server.

If you are using shared hosting, you will only have one user. Use your host's file managing app to verify you have write permissions for these directories:

  • vendor (Composer or compressed archive installation)
  • app/etc
  • pub/static
  • var
  • generated
  • Any other static resources

If you are using private hosting, you will need two users: one to log in, and another to run the web server. Both users need to be in the same group for this to work properly.

See Magento's documentation on pre-installation ownership and permissions for more details on pre-installation for both shared and private hosting.

Installing Magento Using Composer

One of the most popular methods of installing Magento is by using Composer. Here is how to do that.

Install Composer

We will be using composer to install Magento, so you will need to install Composer first if you haven't already. To do so, enter the following code from the command line:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '48e3236262b34d30969dca3c37281b3b4bbe3221bda826ac6a9a62d6444cdb0dcd0615698a5cbe587c3f0fe57a54d8f5') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

This will install Composer in the current directory, so do so either from the directory that is part of your PATH (to install it globally) or do it from within a directory for Magento if you only want to install it locally.

Get Your Authentication Keys

Magento 2 and third-party Composer packages are stored in repo.magento.com and you need authentication to access them. To do this:

  1. Go to the Magento Marketplace and login or register an account if you don't have one.
  2. Go to the top right corner of the page and select My Profile
  3. Click Access Keys in the Marketplace tab
  4. Click on Create a New Access Key. You will be prompted to enter a name for the keys, such as the name of the developer who will be working with them. Enter a name and click OK.
  5. Public key and a Private key will be generated. Save this information. You will be using the Public key as your username and the Private key as your password.

Get The Magento Metapackage

You will need to get the metapackage in order to install Magento. Here's how.

  1. Log into your Magento server as the Magento file system owner, or switch your server user to the Magento file system owner, that you set up above.
  2. Switch to the docroot directory, or a virtual docroot directory.
  3. From the command line, enter the Composer command to create a Composer project with the Magento Open Source or Magento Commerce metapackage.
    • Magento Open Source command:
      composer create-project --repository=https://repo.magento.com/ magento/project-community-edition <install-directory-name>
    • Magento Commerce command:
      composer create-project --repository=https://repo.magento.com/ magento/project-enterprise-edition <install-directory-name>
  4. Enter your public key for your username and your private key for your password.
  5. If you haven't set these permissions already, execute the following commands from the command line:
    cd /var/www/html/
    find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +
    find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} +
    chown -R :www-data . # Ubuntu
    chmod u+x bin/magento
  6. Install Magento from the command line as described in the next section.

Installing Magento From The Command Line With Composer

Use the following commands to install Magento from the command line. In this example, the Magento install directory is called magento2ee, the db-host is on localhost, and that db-name, db-user, and db-password are all magento.

bin/magento setup:install \
--base-url=http://localhost/magento2ee \
--db-host=localhost \
--db-name=magento \
--db-user=magento \
--db-password=magento \
--backend-frontname=admin \
--admin-firstname=admin \
--admin-lastname=admin \
--admin-email=admin@admin.com \
--admin-user=admin \
--admin-password=admin123 \
--language=en_US \
--currency=USD \
--timezone=America/Chicago \
--use-rewrites=1

Start Using Magento

If you finished these steps correctly, you have finished installing Magento using Composer and it should work as expected.

Install Magento From A Compressed Archive File

If you don't want to install using Composer and instead want to install Magento using a compressed archive file (.zip or .tar) these are the steps you'll need to follow.

First, make sure you meet the system requirements and have created a Magento File System Owner as discussed at the beginning of this post.

Download The Magento Software

download magento releases

Credit Magento

After making sure the server requirements are met and the Magento File System Owner is properly created, you will need to download the archive to install it.

Magento Open Source

To get the Magento Open Source archive, go to https://magento.com/tech-resources/download and navigate to Full Release with Sample Data. You can also navigate to Full Release (ZIP with no Sample Data) if you want a version without any examples to help you learn Magento. Click the Select your format drop down and select which version of .zip or .tar you want to use for your file compression. Click the Download button to download the compressed archive.

download magento open source

Magento Commerce

To get the Magento Commerce archive, start by going to https://magento.com/.

Next, click the My Account icon in the top right corner of your browser window:

magento my account

Create an account if you haven't already, and log in with your Magento username and password.

From the left sidebar, click Downloads. From the Downloads page, go to the appropriate Magento Commerce version (we recommend a + Sample Data version), then select your file format and download the file.

Transfer The Magento Archive To Your Server

After downloading the appropriate Magento Archive, you will need to transfer it to your server. Here is how:

  1. Download and install an FTP client such as FileZilla if you haven't already.
  2. Connect your FTP client to your Magento server according to your FTP client's documentation.
  3. Select the compressed file to upload from your computer.
  4. Select the docroot directory on your server to upload the compressed file to. This is often called public_html. Here is an example of selecting the compressed file on your system and selecting the docroot directory in your FTP client:magento ftp
  5. Transfer the archive from your computer to the server using the FTP client.
  6. Allow the file time to complete uploading to the server.
  7. Log onto your Magento server and switch to the Magento File System Owner if needed.
  8. Switch to the docroot or virtual docroot directory (e.g. public_html)
  9. Create a Magento subdirectory.
  10. Copy the Magento archive to the directory, for example:
    cp /var/www/Magento-CE-2.0.0+Samples.tar.bz2 magento2

Extract (Decompress) The Magento Archive

After logging into your Magento directory and switching to the Magento File System Owner if necessary, extract the Magento file from the command line:

  • tar zxf <filename> to extract a .tar.gz file
  • tar jxf <filename> to extract a .tar.bz2 file
  • unzip <filename> to extract a .zip file

Once the archive finishes extracting, delete the compressed file or move it to a different directory.

Now make sure your permissions are set as discussed in the Create A Magento File System Owner section at the beginning of this post before continuing.

Install Magento

Now that you have decompressed the Magento archive, it is time to install it. There are two ways to do this: from the command line and using the Setup Wizard. The method for installing through the command line is different from the Composer method discussed above, so be sure to use the following method, not the one discussed earlier.

Installing Magento With The Raw Files From The Command Line

If needed, log in to your Magento server and switch to the Magento File System Owner. You can run Magento commands from any directory if you add [your Magento install directory]/bin to the system PATH.

A completely secure installation is recommended, meaning that both the storefront and the Magento Admin run on SSL. Set these parameters:

  • --use-secure: Set to 1
  • --base-url-secure: Set to a secure URL (that is, starting with https://)
  • --use-secure-admin Set to 1

Review Magento's documentation on the command line interface and installing Magento through the command line interface for a comprehensive guide. We will provide an example that makes the following assumptions:

  • The storefront URL is http://127.0.0.1
  • The database server and host server are on the same host
  • The database name, username, and password are all magento
  • You use server rewrites
  • The Magento administrator's:
    • first and last names are Magento and User
    • username and password are admin and admin123
    • email address is user@example.com
  • The default language is en_US
  • The default currency is US dollars
  • The default time zone is US Central

Under these assumptions, the install commands are:

magento setup:install --base-url=http://127.0.0.1/magento2/ \
--db-host=localhost --db-name=magento --db-user=magento --db-password=magento \
--admin-firstname=Magento --admin-lastname=User --admin-email=user@example.com \
--admin-user=admin --admin-password=admin123 --language=en_US \
--currency=USD --timezone=America/Chicago --use-rewrites=1

To verify your install was successful, navigate to your store's homepage URL. The sample storefront that came with your download should display.

Installing With The Setup Wizard

magento setup wizard readiness check

Credit Magento

The Setup Wizard is a visual interface you can use to install Magento. It will go through several pages, none of which can be skipped, and all of which need you to complete all required fields before going to the next page. You have the option of returning to previous pages if you made a mistake, or you can exit and run the installer again.

To install, after logging into your Magento server and, if necessary, switching to the Magento File System Owner:

  1. Open your web browser and enter the URL for the setup wizard, which takes this form:
    http://<Magento host or IP>/<path to Magento root>/setup
    For example, if the IP address is 192.0.2.10 and Magento 2 is installed in the magento2/ directory (under the docroot directory), and assuming there is no virtual host, the URL would be:
    http://192.0.2.10/magento2/setup
  2. The Setup Wizard will launch. On the starting page, click Agree and Set Up Magento to get started.
  3. On the next page, click Start Readiness Check.
  4. To see more information about each part of the readiness check, click on More detail, then click Next
  5. To add your database, enter the required information in each field:
    • Database server host: Enter localhost if the web server and database are on the same host. Enter the hostname or IP address for your database otherwise.
    • Database server username: The username that owns your Magento database instance.
    • Database server password: Leave it blank if you never set up a password, or enter the password associated with the username that owns the Magento database.
    • Database name: Self explanatory.
    • Table prefix: Leave it blank unless you have more than one instance of Magento running on a server with shared tables in the same database. The prefix identifies the tables associated with this Magento installation so that you can run multiple Magento installations using the same database server.
  6. Click Next.
  7. For web configuration, complete these required fields:
    • Your store address: Your store's complete URL, including the trailing slash at the end (e.g. https://www.example.com/)
    • Magento admin address: The relative URL to reach your Magento Admin, such as /admin.
  8. Optionally, click Advanced Options and set these additional web configuration fields, although we hardly consider the first option to be actually optional in the modern ecommerce landscape:
    • HTTPS Options: We highly recommend checking this box to enable SSL and run your site as HTTPS. Your server will need to have SSL support for you to do this. Google currently gives sites a slight rankings boost for SSL and the Chrome browser displays a warning on every page that doesn't use HTTPS.
    • Apache rewrites: Allows Magento to use Apache rewrites, assuming this was enabled when you installed Apache.
    • Encryption key: Sensitive data is protected by an encryption key. Select whether you want this key to be generated by Magento or if you want to use your own (which requires you to already have one)
    • Session save: Select how you want Magento session data stored. The default, Files, stores session data in the var/session subdirectory. Db stores it in the database tables.
  9. Click Next
  10. To customize your store:
    1. Select your timezone under Store Default Time Zone
    2. Select your currency under Store Default Currency
    3. Select your store's language under Store Default Language
    4. Optionally, expand the Advanced Modules Configuration section to enable or disable modules. If this is your first time installing Magento we recommend against this. See Magento's documentation for details.
  11. Click Next
  12. To create your Magento Admin account, complete these fields:
    1. New Username: The username for your Magento administrator, which has the power to create other users (including more administrators).
    2. New E-mail: The email address for your Magento administrator.
    3. New Password: The password you will use to log into Magento with for your administrator user.
    4. Confirm Password: To avoid password mistakes, enter your password a second time.
  13. Click Next
  14. Now it's finally time to actually install Magento itself. Click Install Now to begin.
    • Click Console Log to see installation progress if you want.
    • If there is an error, click Previous to fix erroneous entries in the Wizard.
    • Click Try Again if there is an installation error that does not appear to be caused by a data entry error.
  15. You will see a Success message when the installation completes.
  16. Verify your installation by going to your browser and entering your store URL. You should see the sample store included with your download.

Installing Magento From A Magento Repository Clone

The third option for installing Magento is to install it from a clone of the Magento Repository. This option is for contributing developers only, that is, developers who contribute to the Magento codebase and heavily customizes their Magento install. The option allows you to use the command line or the Setup Wizard to install, but you cannot use Magento in a production environment. You also cannot upgrade Magento with the Web Setup Wizard.

Since this option is for highly technical users, we will refer you to Magento's documentation.

All Set

Now that Magento is installed, you are ready to start setting up your store and configuring Magento to optimize your SEO. See our other posts on Magento and it's associated SEO considerations.