X
    Categories: Magento 2 BlogsMagento Tutorials, Tips and Guides

How to Install Magento 2.x on Debian Server

Magento uses PHP, which means that the Magento platform is an open source ecommerce application that many merchants use to operate their eStores. On most of the Linux distributions, it operates using the LAMP stack. Magento is a resource-intensive application that needs at least 1GB if the store is small, but 4GB for medium to large stores.

Magento 2 has been released with more functionalities and the back end interface has been improved. A front end library was also introduced.

Previously, I had written an article on Magento 1.x installation on Debian Server, and now in this tutorial, I am going to show you how to install Magento 2.x on Debian server.

Why Use Cloud for Magento 2?

Choosing a Magento Hosting solution may be a terribly troublesome conundrum for several online businesses. On top of providing customers with the best ecommerce functionalities, several web hosting service suppliers are also capable of providing you with a web server to host your website, together with an email server and different standard web-hosting options. However, if you would like real, quick, and secure ecommerce hosting, you can use cloud infrastructure providers, like AWS, DO, GCE, and Vultr.

The cloud provides better performance, scalability, user experience, and frontend

Getting Started

In order to install Magento 2, you first have to install the MySQL database. And then make a database for your application.

To setup the database, the steps are mentioned below:

1. Create the Database

First, log into the MySQL root account by using the following command:

mysql -u root -p

After this, the system will ask you the password. Simply enter the correct password that you set during installation of MySQL and you are then taken to MySQL command prompt. Now create your database. You can name your database whatever you prefer. I have named it mage2_db

create database mage2_db;

This command will create a database for your Magento 2 system.

PS: Don’t forget to put (;) semicolon at the end of every MySQL command.

2. Create the User Account

Now you have to create a user account for the database to operate the newly created database.

Again, you can name your user account whatever you want and can set a password as you prefer. Mine will be mage2_user for the account name and password is fayyaz. The more secure the password more secure your database will be

create user 'mage2_user'@'localhost' identified by 'user1’;

3. Granting Privileges

We are done creating the database and user account, especially for Magento. Now you need to setup the privileges for the user you just created. To grant all the privileges the command is:

GRANT ALL PRIVILEGES ON mage2_db . * TO mage2_user @localhost;

4. Flush the Privileges

After the above step, your user has access to the newly created database. You need to flush the privileges so that MySQL will get to know about the privileges that we have granted to the newly created user on the newly created database. After flushing out, just exit out of the MySQL command prompt.

FLUSH PRIVILEGES;

After exiting, you will get back to SSH command prompt. And your database has successfully finished installing at this point.

After exiting, you will get back to SSH command prompt. And your database has successfully finished installing at this point.

Downloading Magento 2

Now, get ready to download and install the Magento 2 files. It is recommended that you download the latest version. The reason for downloading the latest version is that it often includes the important security updates in addition to improved new features. The following are the steps for setting up the files.

1. Extract the Files

Use wget to download the Magento 2 files and archive to your home directory.

cd /var/www/public_html
wget https://github.com/magento/magento2/archive/2.1.0.zip

Now extract the zip file using this command.

unzip 2.1.0.zip

Run “’composer install” command under your Magento 2 directory. Or if you face error in installing composer, use these two commands below to install required extensions for Magento 2:

apt-get install php5-intl
apt-get install php5-xsl

After this, make sure you have changed the value of “always_populate_raw_post_data = 0.” in -1 in your PHPini file.

Note: There is an easy way to edit the php.ini file. Follow the below commands:

cd /etc/php5/apache2/
vim php.ini
cd /etc/php5/clid
vim php.ini

To save your editing in php.ini file, simply enter:

qw

2. Assigning Ownership

Now you need to assign the ownership of the files and folders to Apache’s user and group. To do so, the command is:

sudo chown -R www-data:www-data /var/www/public_html/

P.S. Take care of the case-sensitivity here. “R” should be capital.

After this command is run successfully, you have allowed the Apache server to create and modify these files.

Carrying on With Frontend

To complete the installation, you now need to configure it through the web interface. To access the interface, you have to open up your browser and then type in the server’s domain name or public IP address in the address bar.

http://server_domain_name/

I will now tell you about all the pages, step by step.

1. Welcome Page

Now, if the above steps have been completed successfully, your Magento 2 system will allow you to access this welcome page to set up the Magento installation. On this page, you will need to hit the Agree and Setup Magento button.

2. Readiness Check

On this page, the system checks whether your system is up to date for Magento 2 or not. Hit the Start Readiness Check button and if it is successful, then click the Next button at the top.

3. Add Database

On this page, enter the database information that you just entered creating one above.

Database Server Host: Your host here should be localhost.

Database Name: Make sure that you put the name of the database that you decided during the creation of the MySQL database.

Database Server User Name: Put the username that you decided during creation of the user account.

Database Server Password: Fill in the password that you put during the creation of the user account.

Tables Prefix: This field is optional. If you want to put any prefix before the table names, then fill out this field.

After filling the above fields, you have to jump to the second section by clicking the Next button.

4. Web Configuration

This page allows you to enter the information about the store and the admin:

Your Store Address: Enter the address of your store that is entered in the browser to reach the front of the store.

Magento Admin Address: Enter the admin address which is entered in the browser to reach the admin panel.

After filling the above fields, you have to jump to the second section by clicking the Next button.

5. Customize Your Store

Select the Time Zone, Currency and Language to set up your store.

After filling the above fields, you have to jump to the second section by clicking the Next button.

6. Create Admin Account

Enter the information required:

New Username: Enter the name of the admin of your store.

New Email: The email address of the admin.

New Password: The password which the admin uses to enter the account.

After filling the above fields, you have to jump to the second section by clicking the Next button.

7. Install

All you have to do on this page is to click the Install button and the installation will begin.

If you want to see the installation process click below at Console Log.

8. Success

After the Magento 2 installation is done successfully, it is ready to use.

Put your public IP or the domain name on the address bar of the browser and see the front of your store.

If you have successfully configured the above steps, you will be directed towards the Home Page of your Magento 2 store.

Also, you can visit this page by just using the command

http://server_domain_name/admin/

To see the dashboard, you just have to login to the system using the username and password that you have already set above. If the info you provided is correct, you will be redirected towards the Magento 2 admin dashboard that will look like this.

After going through all the steps above, your Magento 2 store is setup on the Lamp Stack and is ready to go. Now you can use it and start operating your Magento 2 store so that you can sell your products and delight your customers. Also, now you can set up the promotions for your store.

Which Provider Is the Best?

This tutorial has given you a brief idea about choosing cloud hosting for your Magento 2 store, but the question still remains what provider will give the best services. Cloudways provides you only one-click installation of Magento 2 platform, so it will be very easy for you to launch your Magento 2 store on a Cloudways managed server.

Cloudways is a PaaS supplier that empowers the cloud suppliers and offers you professional expertise with Magento Hosting. Try Cloudways for 14-days trial on DigitalOcean Cloud server. They even have a useful tutorial so that you can install it on your Cloudways server, ohow to host Magento 2 on cloud.

Still, if you have questions or want to give feedback, then feel free to contact me. So, what you are waiting for? You have this tutorial, start up your Magento store by following it!

Fayyaz Khattak: Fayyaz is a Magento Community Manager at Cloudways - A Managed Magento Hosting Platform. His objective is to learn & share about PHP & Magento Development in Community. Fayyaz is a food lover and enjoys driving. You can email him at m.fayyaz@cloudways.com