Install Magento on Ubuntu 16.04

Install Magento on Ubuntu 16.04

Introduction

Magento is an eCommerce open source software, and a content management system for eCommerce websites. It uses MySQL 5.6+ or MariaDB as possible databases, and it’s compatible with both NGINX and Apache web servers. It also requires PHP7+ and some of its extensions.
This tutorial demonstrates how to install Magento 2 on an Ubuntu 16.04 server using NGINX and MySQL.

Getting started

Update the server

First check for updates, and then install:

# apt update

Install NGINX

NGINX is available on Ubuntu repository, so you can easily install it with apt:

# apt install nginx

Install PHP

Since you are likely hoping that the site will be accessed by many visitors, it’s better to install PHP-FPM (FastCGI Process Manager), which has various features. So, install it and the extensions required by Magento:

# apt install php7.0-mcrypt php7.0-fpm php7.0-curl php7.0-mysql php7.0-cli php7.0-xsl php7.0-json php7.0-intl php7.0-dev php-pear php7.0-mbstring php7.0-common php7.0-zip php7.0-gd php-soap

Install curl as well:

# apt install curl libcurl3
Editing PHP settings

Modify the two configuration files:

  • /etc/php/7.0/fpm/php.ini – FPM configuration;
  • /etc/php/7.0/cli/php.ini – PHP-CLI configuration file;

In both, add the following lines (or edit if already existing):

memory_limit = 2G
max_execution_time = 3600
opcache.save_comments = 1
zlib.output_compression = On

Save, exit and restart PHP-FPM so that changes will be applied:

# systemct restart php7.0-fpm

Install and configure MySQL

To install MySQL, execute the following command:

# apt install -y mysql-server mysql-client

Next, set up a root account for it:

# mysql_secure_installation
Set root password? [Y/n]
New password:
Re-enter new password:
Remove anonymous users? [Y/n]
Disallow root login remotely? [Y/n]
Remove test database and access to it? [Y/n]
Reload privilege tables now? [Y/n]

If importing a large numbers of products into Magento is required, just increase the value for the max_allowed_packet option using the following code:

# $EDITOR /etc/mysql/mysql.cnf

There, search for the mentioned line, and modify as follow:

[mysql]
max_allowed_packet=64M

Save, exit and restart MySQL:

# systemctl restart mysql

Next, start a MySQL command prompt:

# mysql -u root -p

Create a new user and database:

mysql> CREATE DATABASE magento_db;
mysql> CREATE USER 'magentousr'@'localhost' IDENTIFIED BY 'user_strong_password';
mysql> GRANT ALL PRIVILEGES ON 'magento_db.*' TO 'magentousr'@'localhost' IDENTIFIED BY 'user_strong_password';
mysql> FLUSH PRIVILEGES;
mysql> EXIT;

Downloading Magento

Magento 2 will be installed in the /var/www/magento2 directory. The installation requires PHP Composer. Install PHP Composer by executing the following command:

# curl -sS https://getcomposer.org/installer | php

Move the composer.phar file to /usr/local/bin:

mv composer.phar /usr/local/bin/composer

Test that everything is going smoothly so far with:

# composer -v

This should print out the composer version.

To obtain Magento (the Community Edition, in this tutorial), first go to https://www.magentocommerce.com/magento-connect/ and create an account there. Next, follow My Account > Developer > Secure Keys, and generate new keys.

Now it’s time to download Magento. On a terminal, execute the following command:

# composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition /var/www/magento2

During this process, use the public key for username and the private key for the password.

Configure a Virtual Host

Create a new Virtual Host file:

# $EDITOR /etc/nginx/sites-available/magento

In the Host File, paste the following configuration:

upstream fastcgi_backend {
        server  unix:/run/php/php7.0-fpm.sock;
}

server {

        listen 80;
        server_name www.myecommerce.com;
        set $MAGE_ROOT /var/www/magento2;
        set $MAGE_MODE developer;
        include /var/www/magento2/nginx.conf.sample;
}

Magento already contains an NGINX configuration file, so it’s not necessary to create one.

Save and exit.
Next, activate the virtual host:

# ln -s /etc/nginx/sites-available/magento /etc/nginx/sites-enabled/

Restart NGINX:

# systemctl restart nginx

Install Magento

In /var/www/magento2 there is a binary file named magento. This will be used for installing Magento 2.
Execute:

# /var/www/magento2/bin/magento setup:install --backend-frontname="admin" \
--key="cja8Jadsjwoqpgk93670Dfhu47m7rrIp"\
--db-host="localhost" \
--db-name="magento_db" \
--db-user="magentousr" \
--db-password="usr_strong_password" \
--language="en_US" \
--currency="USD" \
--timezone="My/Timezone" \
--use-rewrites=1 \
--use-secure=0 \
--base-url="http://www.myecommerce.com" \
--base-url-secure="https://www.myecommerce.com" \
--admin-user=admin \
--admin-password=admin_password \
[email protected] \
--admin-firstname=admin \
--admin-lastname=user \
--cleanup-database

At the end:

[SUCCESS]: Magento installation complete.
[SUCCESS]: Magento Admin URI: /admin

Final configuration

As usual in cases like this, the last step is a “graphical configuration” through a web browser. Go to www.myecommerce.com/admin, and log in with the admin credentials you created during the installation process.
After signing in the Magento Dashboard should appear, signifying that everything went well. The ecommerce web site is now ready to be filled with products!

  • I have been on many systems but nothing worked well for me in a proper way. At last in 2012 I discovered a system which is crazy. It is extremely simple and easy to setup and I started advertising it within few mins.This program works and is perfect for everyone regardless of age,educational background or occupational skills.You can get immediate results even if you feel like you have sup-par computer skills.I have earned $1000 during my initial 7-day period and after that I am earning $10000 or even more monthly.Thank you for creating this amazing system that is perfect for the average person >>>> http://deliciousurl­.­com//1w

  • In case you searching for stable web based home-based advertising opportunity but yet sick and tired of on-line frauds in that case this is actually what you need. I commenced working on this work 2 years back and taking home Seven Thousand bucks per mnth easily. Start earning income just like me… Check out the >>>>>>>>>>> http://v15­.­uk/a703L

  • This post rocks. It really helped me.

  • Being profitable over the internet is just as unproblematic (and also as problematical) just as making extra money off-line. Though tens of thousands of Internet website marketing masters guarantee to possess a secret method process in making instant cash, the the reality is, you will not method one may turn out to be rich as soon as possible as a result of clicking on a button or simply choosing various ebook. Generating revenue via internet requires some hard work and also perseverance. For anyone who is willing to put in the required time and consequently energy into it, there are a lot of approaches for bringing in some extra wealth using the net.I am being paid $10 thousand or perhaps many more per thirty days out of this job.Here’s the quick way to make a profit though the others are longer term home money making ideas >>>>> OUOURL.COM/4rgu

  • Have you consistently received very much money without offering it for sale any-thing or perhaps without accomplishing any direct selling form of work and not having to invest anything at all. I would like to share with you a job wherein all specialty tools will be presented to you and even it truly is a very simple and also easy gig. Not necessary to startup your personal domain names for example., almost all are going to be presented to you at absolutely no cost. Folks will certainly take a look at your main site so you are going to get remunerated for that. Its as easy as that. I’m earning a good amount of money from a home office because of this project like $20000 regular monthly or more in case you also wants to take home money similar to that then follow these specific not difficult facts by checking out this web site >>>>> URL4.UK/itzyZ

  • Wᴑгk fr౦ʍ һoм℮ ſ౦r 2‒Ꮾ hrs ᑯɑᎥlʏ, and ᶃet ϱаͺᑯ fr٥ʍ ןk⁃3k on weekΙy ᏏɑsᎥs܂ Read m౦re inf๐rmatɪon հere› V15.UK/coMxt