September 20, 2019 / Nirav Shah
Step 1: Install Apache2 HTTP Server on Ubuntu
sudo apt update
sudo apt install apache2 -y

Step 2: Install MariaDB Database Server
sudo apt-get install mariadb-server mariadb-client

sudo mysql_secure_installation

sudo mysql -u root -p

Step 3: Install PHP 7.1 and Related Modules
sudo apt install php7.1 libapache2-mod-php7.1 php7.1-common php7.1-gmp php7.1-curl php7.1-soap php7.1-bcmath php7.1-intl php7.1-mbstring php7.1-xmlrpc php7.1-mcrypt php7.1-mysql php7.1-gd php7.1-xml php7.1-cli php7.1-zip
Step 4: Restart Apache2
sudo systemctl restart apache2.service

sudo vim /var/www/html/phpinfo.php

<? phpinfo( ); ?>

Step 5: Create Magento 2 Database
sudo mysql -u root -p

CREATE DATABASE magento2;

CREATE USER 'magento2user'@'localhost' IDENTIFIED BY 'new_password_here';

GRANT ALL ON magento2.* TO 'magento2user'@'localhost' IDENTIFIED BY 'user_password_here' WITH GRANT OPTION;

FLUSH PRIVILEGES;

exit
Step 6: Download Magento 2 Latest Release
sudo apt install curl git

curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin -- filename=composer

cd /var/www/html

sudo composer create-project --repository=https://repo.magento.com/ magento/project-community-edition magento2

Public key Private key
Step 7: Create the user
cd /var/www/html/magento2

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

sudo chown -R www-data:www-data /var/www/html/magento2/

sudo chmod -R 755 /var/www/html/magento2/

sudo vim /etc/apache2/sites-available/000-default.conf

DocumentRoot /var/www/html/magento2/
<Directory /var/www/html/magento2/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

sudo a2enmod rewrite

systemctl restart apache2


As a Director of Eternal Web Private Ltd an AWS consulting partner company, Nirav is responsible for its operations. AWS, cloud-computing and digital transformation are some of his favorite topics to talk about. His key focus is to help enterprises adopt technology, to solve their business problem with the right cloud solutions.
Have queries about your project idea or concept? Please drop in your project details to discuss with our AWS Global Cloud Infrastructure service specialists and consultants.