Title: How To Setup and Configure Latest Magento 2.x On Linux EC2

This guide explains the steps to install and configure latest Magento 2.x on a Linux ec2 cloud server or a VPS. We will be doing the following.

  1. Setting up LAMP Stack (Mysql version 5.6 or later)
  2. Setting up Database and user (CLI and PHPMyAdmin)
  3. Setting up Magento 2.0 using composer.

I am using an Ubuntu 14.04 LTS server from Amazon ec2. This tutorial will work on any cloud or VPS having a Ubuntu server.

Setup LAMP Stack

1. Update the Server

2. Install apache

3. Install MySQL server and the PHP module for MySQL. During installation, MySQL would prompt for the password for the root user. Set a strong password.

4. Create MySQL database directory using the following command.

5. Run the MySQL secure installation command.

The above command would prompt for the root password. Enter the root password and proceed with the options given in the output below.

6. Install PHP.

7. Open /etc/apache2/mods-enabled/dir.conf file using vi or nano editor.

The file would look like the following.

Move index.php to first so that the file would look like the following.

8. Restart apache server.

9. To know all the PHP details, create a file named info.php

Copy the following contents on the info.php file.

Now, if you browse to http://<Server-IP>/php.info, you will be able to see all the PHP configuration details.

READ  How to Setup Custom UI Theme For Jenkins

Install and Configure PhpMyAdmin

PhpMyAdmin is a great utility for managing databases through GUI. Follow the steps carefully for setting up PhpMyAdmin.

1. Install PhpMyAdmin

When it prompts for web server, press space bar and select apache2 and press enter. For Configure database for PHPMyAdmin, press enter. Password of the database’s administrative user, enter the root password for MySQL that you created during MySQL installation. Enter the same password for confirmation.

2. Enable PHP mcrypt module.

3. Restart the web server.

Now you can access the PhpMyAdmin Web UI by visiting the ec2 public IP address followed by PHPMyAdmin as shown below.

You can use the MySQL root credentials to log in to PHPMyAdmin account.

Create Magento User and Database

You can create MySQL user and Database using the command line as well through PhpMyAdmin. Using PHPMyAdmin is self-explanatory. If you want to use the command line for creating the user and database, you can follow the steps given below.

1. Sign into MySQL client using the root user and password.

2. Create database Magento.

3. Create a magento_admin with a strong password. Replace “password” with your strong password.

4. Grant all privileges to magento_admin for Magento database. Replace password accordingly.

5. Flush all the privileges and exit the MySQL CLI.

Setting up Magento

In this section, we will configure Magento using LAMP stack. Follow the steps carefully.

1. Create a file called magento.conf in the apache sites available folder.

Copy the following content on the file.

2. Enable our new conf and disable the default conf using the following commands.

3. Reload the apache service.

READ  Setting Up Azure CLI on Ubuntu Linux

4. Open php.ini file to increase the memory_limit parameter to 512M (default 128M).

Find memory_limit parameter and set it to 512M and save the file.

5. Install required PHP modules for Magento.

6. Enable rewrite, mcrypt module and restart the apache server.

Setup Magento 2.X

1. Install Composer.

2. Create a Magento marketplace account and get public and private access keys from your account. Refer this link for getting the public and private keys

3. Create an auth.json file

sudo vi /root/.composer/auth.json

Copy the following content on to the file with your public and private key.

4. Get the latest Magento binaries using git.

If you don’t have git installed, install it using the following command.

Clone the magento2 community version code to Magento directory.

5. Copy all files to /var/www/html directory using rysync.

6. CD into /var/www/html folder and install all the required Magento modules using composer.

7. Change the owner of /var/www/html to www-data.

8. Visit the public IP of your server. You will see the Magento setup page as shown below.

magento initial setup

 

9. Click agree and setup. Click next for database settings.

magento 2 initial setup

 

10. Enter the database username , password and database name you have created under MySQL configuration as shown below. Click next after entering the details.

magento database configuration

 

11. Next page, you can see the store and admin page address. You can customize the admin age path. If you have a domain name, you can map the domain name to the IP address.

magento 2 admin url confirations

 

From this point, you can click next and fill in the details. In the last page, click “Install” option. Once installed, you will get all the details of your Magento site as shown below.

 

magento final installtion

Free DevOps Resources

Get DevOps news, tutorials and resources in your inbox. A perfect way If you want to get started with devops. Like you, we dont like spam.