How to deploy a website on ubuntu vps server

Today, we will try to install the magento on the ubuntu vps server. It is quite simple by follow these steps.

Buy a domain and link domain to your server via DNS

The first, we need to have a domain and a vps server. I often buy domain on HostGator. And then I buy a VPS server on vultr or digitalocean.
Tips: You can choose a vps server ubuntu with the cheapest price, it is easy to upgrade when you need better performance.
And then I edit DNS of domain to link to vultr vps server

link domain to vps server

I’m working on my localhost. So I can edit the host file of my computer to link a domain to my localhost

edit host to link domain

link domain to localhost

Configure a virtual host to add new domain

The virtual host of apache2 is in folder /etc/apache2/sites-available. We can check by using ssh command line sudo ls -l /etc/apache2/sites-available

sites available apache2

Now, we will create a new file magento1.conf to add new domain named magento1.com sudo nano /etc/apache2/sites-available/magento1.conf
And insert the source code

<Directory /home/magento1.com/public_html>
  Options Indexes FollowSymLinks
  AllowOverride All
  Require all granted
</Directory>
<VirtualHost *:80>
        ServerName magento1.com
        ServerAlias www.magento1.com
        ServerAdmin webmaster@localhost
        DocumentRoot /home/magento1.com/public_html
        ErrorLog /home/magento1.com/logs/error.log
</VirtualHost>

Now, we need to create folders /home/magento1.com/public_html and /home/magento1.com/logs by using command line sudo mkdir -p /home/magento1.com/{public_html,logs}

create root folder website

Then we can enable the site magento1.conf and reload apache2 server by using command line sudo a2ensite magento1.conf and sudo systemctl reload apache2

a2ensite apache2 to enable virtual host

How to install magento on ubuntu server

Download the magento resource and sample data from magento.com and upload them to the folder /home/magento1.com/public_html
Now, you can go that folder and check the source code again cd /home/magento1.com/public_html and sudo ls -l

upload magento resource to server

Unzip the source code by using command line unzip magento-1.9.4.0-2018-11-28-04-28-56.zip and unzip magento-sample-data-1.9.2.4-2016-10-11-07-20-15.zip
Move magento resource from folder by command line mv -f magento/* ./ and cp -rf ./magento-sample-data-1.9.2.4/* ./
Tips: you can use command line sudo apt install unzip to install Zip for your server.

root folder website magento 1

Use ssh command line or phpmyadmin to create a database for your website sudo mysql -u root -p to login mysql and then create database named magento1 create database magento1; and create mysql user named magento1 with full permission on database magento1 grant all on magento1.* identified by "magento1";

mysql create database

Now you can import file magento_sample_data_for_1.9.2.4.sql to database magento1 by using mysql command use magento1; and source magento_sample_data_for_1.9.2.4.sql;

mysql import database

You can open the browser and visit url magento1.com to install the magento website

install magento ubuntu vps

Tips: sudo apt-get install php5.6-curl to install PHP extension “curl”
sudo apt-get install php5.6-soap to install PHP extension “soap”
sudo apt-get install php5.6-gd to install PHP extension “gd”
sudo apt-get install php5.6-xml to install PHP extension “xml”
sudo apt-get install php5.6-mbstring to install PHP extension “mbstring”
sudo apt-get install php5.6-intl to install PHP extension “intl”

How to deploy a website on ubuntu vps server
5 (100%) 2 votes

Leave a Reply

Your email address will not be published. Required fields are marked *