How to Install Magento on Ubuntu 16.04

r00t November 1, 2017

Install Magento on Ubuntu 16.04

In this tutorial we’ll learn how to install Magento on Ubuntu 16.04. We will also install and configure its prerequisites. Magento open source is a flexible e-commerce platform for both developers and smaller businesses. The free open source edition includes all the functionality and features to fulfill the demands of the businesses of today. It’s the perfect platform for developing small company websites or anybody who wishes to understand and experiment with building an online shop.

I recommend to use a minimal Ubuntu server setup as a basis for the tutorial, that can be a virtual or a root server image with an Ubuntu 16.04 minimal install from a web hosting company or you use our minimal server tutorial to install a server from scratch.

Install Magento on Ubuntu 16.04

Step 1. First, ensure your system and apt package lists are fully up-to-date by running the following:

apt-get update -y && apt-get upgrade -y

Step 2. Installing LAMP on Ubuntu 16.04.

You should check out this LAMP stack install tutorial for Ubuntu 16.04, if you haven’t installed LAMP yet. Once it’s installed, come back here and read on. We also will install the required packages for LAMP stack and the important PHP extension that Magento relies on:

apt-get install php7.0-mysql php7.0-curl php7.0-json php7.0-cgi php7.0 libapache2-mod-php7.0 php7.0-mcrypt php7.0-gd php7.0-mbstring php7.0-zip php7.0-dom php7.0-xml

Step 3. Installing Magento.

To install Magento, you must first register on the official Magento site You will also need the login later to get access to the plug-ins.

Once you’ve registered on, you will be taken to the “Products & Solutions” in the upper menu bar to” Products “-> “Community Edition” and then “Download Now”. For your servers you need the latest version of the “Full Release (ZIP with no sample data)”. For “Select your format”, I recommend the “Magento Community Edition 2.*.*.tar.gz”.

Unzip the file to the /var/www/magento/ directory:

tar -xzf magento-CE-2.*.*-****-**-**-**-**-**.tar.gz -C /var/www/

Afterwards, you just have to rename the folder you just created:

mv /var/www/ magento-CE-2.*.*-****-**-**-**-**-**.tar.gz /var/www/magento

Now just set the right permissions for the folders:

chown www-data:www-data –R /var/www/magento/*
cd /var/www/magento
find var vendor pub/static pub/media app/etc -type f -exec chmod g+w {} \;
find var vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} \;
chmod u+x bin/magento

Step 4. Create a database for Magento.

Next, we need to create a database for the Magento installation:

mysql -uroot -p

Run the following command to create a database for Magento:

MariaDB> CREATE USER 'cloud'@'localhost' IDENTIFIED BY 'magentopasswd';
MariaDB> GRANT ALL PRIVILEGES ON magento.* TO 'cloud'@'localhost';
MariaDB> exit

Step 5. Configure Apache web server for Magento.

For this you can take the default config as a template:

cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/magento.conf

Now edit the currently created Config as follows:

nano /etc/apache2/sites-available/magento.conf

Modify the virtual host file for your Magento site to resemble the example below:

<VirtualHost my-domain.tld:80>

ServerName my-domain.tld
ServerAdmin webmaster@localhost
DocumentRoot /var/www/magento/

<Directory /var/www/magento/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All

ErrorLog ${APACHE_LOG_DIR}/error-magento.log
CustomLog ${APACHE_LOG_DIR}/access-magento.log combined

Now just activate the newly created Config, mod_rewrite and SSL:

sudo a2ensite magento.conf && sudo a2enmod SSL && sudo a2enmod rewrite

Step 6. Accessing Magento Web Installation.

Now you can access the Magento web install wizard in your browser by entering the domain name or http://your_ip/ to continue your Magento installation.

Congratulation’s! You have successfully install and configured Magento on your Ubuntu 16.04 server. Thanks for using this tutorial for installing Magento open source e-commerce on Ubuntu 16.04 LTS (Xenial Xerus) system.


The Tags:

Leave a Comment

Comments are closed.