Install Magento 2 On Debian 9 Digital Ocean Server from Scratch

Install Putty or another SSH client and then connect to the command line console.
By default, there is no password on MySQL.
aptget install mcrypt
sudo chown R wwwdata:wwwdata /var/www/public_html/
To open Magento installation on a browser, use your IP ADDRESS/FOLDERNAME

  • 4GB of Storage
  • 2GB of RAM
  • Any Cloud Server of Your Choice
  • Debian OS – We will be using Debian 9
Now, install the Mcrypt module for PHP.
Now, edit the PHP.ini file in the Apache 2 folder.

Next, you will have to install the PHPMyAdmin interface to manage the database. Type the command:

Cloud Vs Other Hosting Solution

You will get a list of files and folders. Open the folder that has the exact name as the file that you recently unzipped to install Magento.
Next, you need to assign ownership of all Magento files to Apache folder.

Why Choose DigitalOcean As Your Cloud Hosting Partner?

allow_url_fopen = On
MySQL will now install successfully on your DigitalOcean dedicated cloud server.
create user ‘mage2_user’@‘localhost’ identified byuser1;
We solved it by adding mcrypt package to PHP with the following command:

Professional Documentation 

To avoid you from the constant headache, puffy eyes due to a lack of sleep, and regret for not having a Magento expert. We have prepared this detailed guide to install to host your ecommerce store on a server of DigitalOcean Magento 2.

Affordable Pricing 

sudo aptget install php7.1mcrypt

Active Community

Now restart the apache2 digital ocean server by typing the following command:

Remarkable Performance

Next, update the packages.

  • DigitalOcean provides Dedicated IP addresses.
  • Multi-factor authentication
  • Easily resize the nodes.
  • Data centers across popular geographical locations

Installing LAMP Debian 9 on DigitalOcean Server

memory_limit = 256M
<?php echo phpinfo();?>

Connect with the Debian 9 DigitalOcean Magento Server

php r “unlink(‘composer-setup.php’);”
To check where Magento is installed on the server, press ‘ls’
Change the directory to public_html folder of Apache by typing the following command.
On top of that, DigitalOcean provides a simplified cloud web structure for software developers and it is reliable, economical and highly scalable. If we talk about the fact, launching and setting up the Magento DigitalOcean server is a bit difficult, but Cloudways simplifies it with-in a few clicks.
We will add the instruction to .htaccess file so only our IP address can access the PHPMyadmin from the browser.
Go through the prompts.
upload_max_filesize = 100M
Your store IP will be shown here. You can change the admin address of the Magento folder. Make it something that only you can remember.
Once done, press ESC to exit the file. Now, save it by typing ‘:wq’ in the console.

Installing Apache2 on Debian 9 DigitalOcean Magento Cloud Server

Optioning DigitalOcean will create an opportunity for you to extensively scale your online business which is capable enough to run parallel across multiple cloud servers without compromising on performance.

service apache2 restart

order allow,deny


Now Cloud hosting is the best solution we are left with, which offers the best mix of performance, resource availability and scalable infrastructure to scale the server resources when needed.
mv html public_html
The mcrypt module will come in handy when we start installing Magento.
sudo aptget install zip  – Not necessary if you are just unzipping the file, but you can install it anyway.

Phew… that was tiring. Let’s see if there is a better and easier way available.
By leveraging the DO community, you can communicate with a bunch of people to know more about cloud server and also get the answer to all your queries from experts.
Change the always_populate_raw_post_data value to ‘-1

Where is Magento Installed on DigitalOcean Debian server?
That’s it, Magento is successfully installed on your system.

Installing MySQL on Debian 9 Magento DigitalOcean Dedicated Server

php composersetup.php
vim .htaccess
Next, we will install GIT to the server using the command…
Before we start installing Magento on DigitalOcean, we will have to install LAMP on Debian. Why LAMP? Because…
To edit the PHPini file, use the following commands:
By typing the above command you can enter ‘www’ directory. Now, rename file.
Apache is a PHP web server that runs almost 50 percent of the websites. It is an essential component for installing PHP and then Magento. So, you have to run the following command to install Apache 2 on Debian server:
date.timezone = America/Chicago
php r “if (hash_file(‘sha384’, ‘composer-setup.php’) === ’48e3236262b34d30969dca3c37281b3b4bbe3221bda826ac6a9a62d6444cdb0dcd0615698a5cbe587c3f0fe57a54d8f5′) { echo ‘Installer verified’; } else { echo ‘Installer corrupt’; unlink(‘composer-setup.php’); } echo PHP_EOL;”
That’s the beauty of using a managed cloud hosting solution for your Magento ecommerce store. No errors. No waste of time. No hassle. And, most importantly… no stress.

  • Press N if you don’t want to change the root password.
  • Next, press Y if you want to remove anonymous users.
  • Now, press if you want to disallow root login remotely and hit enter.
  • If you want to remove test tables and databases press Y and hit enter.

mysql u rootp

Install PHP 7.1 on Debian 9 DigitalOcean dedicated server

aptget install apache2

Mostly, people go with shared hosting due to the low cost but it would affect the store performance, security and other factors. On the other hand, we have dedicated server hosting which is good in terms of performance but if anything happens with the dedicated server then the business has to suffer in the end. 
Now restart the server to complete the PHP installation process.

First, upgrade your server packages.
If it gives an error, then install the packages that the Magento installation requires.

When you open the IP address, you will see the Magento setup button on the front page
If, for some reason, the above code doesn’t work, then check the official website link for details.
Subscribe to get latest Magento news
file_uploads = On

The following page shows that the symlink is successfully created.
DO offers high server speeds and SSD hard drives along with high performance bandwidth. Moreover,  it also offers:
You need to install these on your Magento DigitalOcean server otherwise Magento will simply not work. So, in this article, I will show you how you can easily setup a LAMP on your DigitalOcean cloud. For this tutorial, I suppose that you have already setup your server with Debian OS 9.
Now press ‘i’ to edit the file.
As you can see that readiness check has confirmed that all settings are proper. We can now start setting up Magento databases.
Now install modules specific to PHP 7.1.
ifconfig eth0 | grep inet | awk ‘{ print }’
Q3. How much does it cost to host Magento on DigitalOcean?
See: How to Install Magento 2 on Localhost Using XAMPP
max_execution_time = 360

Install PHPMyAdmin on Debian

Unless you are a professional Magento developer, installing Magento 2 on your unmanaged cloud server from scratch will be an arduous task. Not only it is time-consuming, but there are tons of errors during the installation that will pop up from time to time and make your installation process unbearable.
sudo apt update
sudo aptget install php7.1 php7.1cli php7.1common php7.1json php7.1opcache php7.1mysql php7.1mbstring php7.1mcrypt php7.1zip php7.1fpm
Get Free Credit on Managed Magento Hosting!
Now, extract the file with the following command.
Now, it is your call. Make a wise decision about installing Magento ecommerce platform because your business depends on it.
Next, we will install MySQL on Debian DigitalOcean dedicated server. MySQL is required for databases and Magento will not work with installing it on your server.
Obviously, a managed hosting solution for your ecommerce store is a perfect choice. However, if you are launching a server for the first time – practicing about how to launch your server, then you can choose an unmanaged Debian server to host LAMP and then Magento.
Next, create an admin account on the Magento ecommerce platform.
First, log into the MySQL database.
vim php.ini

Enable IP Access to PHPMyAdmin

IP address settings changed
Change the PHP version name to the one that you already have installed.
Press ‘I’ to edit the file and enter the following details.

While we were installing Magento on DigitalOcean Debian server, we were short of three PHP packages.
If you already have a user available such as ‘root’ you can also grant it complete privileges on the user.

Install GIT to Debian DigitalOcean Dedicated Server

Press ESC and then press ‘:wq’ to save the .htaccess file.
Once you hit enter, the prompt will ask you to enter the root password again, then hit enter.
cd /var/www/public_html

Create a user account
Next, grant this user full privileges on the database.
You can install all PHP 7.1 module by this one command
Once the download is completed you will see the Apache loading page on the IP address.

Install Magento 2 on Debian DigitalOcean Server

Now, change the folder name from ‘html’ to ‘public_html’ with the following command:
We will use the wget command to download this file to Github. Here is how it works.
A good question. Well, LAMP is an abbreviation of Linux, Apache, MySQL, and PHP. And, since Magento is based on the Zend framework of PHP you need to install that all before you can install Magento 2 on a Debian cloud server. But if that looks too overwhelming, then go for a managed Magento cloud hosting solution.
There you go. We have provided you the complete tutorial about how to launch DigitalOcean Magento server on Debian environment. Apart from that, we have also provided a BETTER ALTERNATIVE for Magento 2 installation with managed cloud hosting.
Next, install PHP 7.1.
You need to create a database in the MySQL folder. This database will be connected with data provided by Magento.
We will install the latest version of PHP on the server. Here is how to do that.
Now only your IP can make changes to the server.

To install Magento from the composer type:
We have found one resource from where you can download Magento 2. 
Once the installation is finished, it will ask you to set your root password.
cd /var/www
That’s it. You have successfully installed Magento on DigitalOcean server.
Press Next.
sudo apt upgrade
Change the following settings in the PHP.ini file so that Magento can easily install on your DigitalOcean cloud.
You can easily launch the DigitalOcean for Magento using managed cloud hosting with the lowest cost of /mo.
Here are some conclusive reasons to choose a DigitalOcean Magento cloud infrastructure:
create database mage2_db;
Q2. Do I need to install LAMP? Why can’t I directly install Magento 2 on Debian?

Next, change the currency settings for your store.
We will assume that you already have your IP address. However, if you don’t have the IP address available then you can use the following command:

By default, PHPMyAdmin is installed in /usr/share/phpmyadmin. You need to create a symlink inside the public_html folder for this purpose. Let’s build the symlink by entering the following commands.
update the packages on the server
rename file

Installing Magento

aptget install phpmyadmin
Apache will create a default file path ‘/var/www/html’ on your server. You will have to rename this file to public_html. To change the filename, open 000-default.conf file with the vim command.
That’s part one of the tutorial. Now, let’s move to the next part i.e. Installing Magento on Debian 9.

Go to IP address and check the settings. They will be changed.

Next, select the location of the server that you want to launch and that’s it. You are done.
cd /var/www/public_html wget 

sudo aptget install unzip
composer update
Now, let’s secure our server so that no other IP address can access the database.

Add the user details that you created earlier. Next, add the database name in the ‘Database name’ tab.
GRANT ALL PRIVILEGES ON mage2_db . * TO mage2_user @localhost;
We know that to install Magento 2 on Debian 9 from scratch on your server is filled with pain. And, we are here with a complete tutorial that will guide you throughout the process like a professional Magento expert so that you can install the platform without worry.
Q1. Which is better for Magento? A managed or an unmanaged hosting solution?

Here is one of the errors:
Now, open your IP address in the browser to check if Magento is moved to the main folder.
Now, update composer with the following command:
Open YOURIPADDRESS/Phpmyadmin from your browser to check if PhpMyAdmin symlink is created.
If you have not already created a user account on MySQL, you can create one using the commands provided below.
allow from <your server ip>
Now edit the index.php file by typing…
Now open your file through the browser to see if it works. It will show the PHP information.
Next, Magento will ask you to test the Readiness check to make sure that you have all the files installed properly.

Note: If the unzip command doesn’t work, then you need to install the package to your system.

Setting up Magento Frontend

The best part about using Cloudways is that you get to choose from five different cloud hosting providers including AWS, Google Cloud, DigitalOcean, Linode, and Vultr.
Most of the times, the Magento folder is created with the zipped file name. Magento is installed in it.

Cloudways platform allows you to host PHP based websites like Magento on DigitalOcean infrastructure and also look after the DigitalOcean update packages.
php r “copy(‘’, ‘composer-setup.php’);”
To exit the file, press ESC. Now, save it by typing ‘:wq’.
sudo nano /etc/php/7.1/apache2/php.ini
We will use the following command to update packages
The best way to grasp the knowledge of any product is through the official documentation, that’s what DigitalOcean offers to their users. DigtalOcean’s documents are comprehensive and concrete which includes tutorials, installation guides and walkthroughs. 
You will have to change the ‘DocumentRoot /var/www/html’ to ‘DocumentRoot /var/www/html
It will update the packages on DigitalOcean Magento 2 server.

sudo aptcache search php7.1
Requirements to Install Magento 2 on Debian 9 using DigitalOcean Server

An Alternative Option – Magento with Managed DigitalOcean Cloud Hosting

Deploying Magento with a Single Click

Problem 1
First, locate the URL where Magento 2 is available for download.

Launching a Cloud Server with a Single Click

This is the package required to unzip files.
Beware: It will take half of your day if you are not too slow. If you are, it will take even more time.
In your terminal, type the following command:

Launch Your Magento Server

sudo aptget install php7.1
ln s /usr/share/phpmyadmin
Note: You can change the name of the database from mage2_db to any other name of your choice.
The basic DigitalOcean pricing plan starts at /mo and the choice of hourly and monthly options makes it more affordable for the individual developers and startups. 
If you see something similar in the PHP folder, then you are successful.
Now, unzip the Magento package.
Press ‘i’ to enter the file editing mode. Now, type:


You can easily launch Digital Ocean on Magento within few seconds.
Flush Privileges so that MySQL knows about the privileges granted to the user.
Easy right?

Frequently Asked Questions for Installing Magento 2 on Debian 9

vim 000default.conf
The ‘cd /var/www/public_html’ is the path where website data is available.

save file
Let’s get started.
Use Coupon: MGT25
cd /var/www/public_html

Subscribe Newsletter

aptget install mysqlserver