== write & share ==

How to create multi websites server in vps Digital Ocean

April 04, 2020

If you do not have an account, you can register an account through the ref link <3. If you have already , continue down the steps below.

Step 1: Create new droplet

Setup SSH

Dashboard -> Account -> Security -> SSH Keys

Or open this Link

Click ‘Add SSH Keys’

(google if you dont know what is this :D)

Create a Droplet

Click ‘Create’ > ‘Droplets’

Select the cheapest package is enough:

  • Distribution: Ubuntu

Choose a plan

  • Starter - Standard: $0.007/hour
  • Choose a datacenter region: any region you, should near your location.
  • Select additional option: SSH Keys
  • Select Project: any project
  • Choose a hostname: test-server-ubuntu

Click ‘Create Droplet’ Button.

You will got the result like this image: SSH

Step 2: Setup theme for your Terminal.

This step is not necessary, but if you do it, it will be more intuitive, making it easier for you to follow these steps.

‘’ is my server, replace with your Ip server.

Login to the server

~ ssh root@

You will get the the message like this

The authenticity of host ' (' can't be established.
ECDSA key fingerprint is SHA256:4XWJdydZwrkfp5IuQ7/9Ic6HDZjtWdYqaGVGcr0gRk0.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '' (ECDSA) to the list of known hosts.
Welcome to Ubuntu 18.04.3 LTS (GNU/Linux 4.15.0-66-generic x86_64)

At the server:

~ vi ~/.bashrc

Press ‘i’ for insert, Esc -> :w -> Save the file. Esc -> :q -> Quit the Vi Editor

  • Copy the below line and add it at the end of .bashrc file:
PS1='\[\033[1;36m\]\u\[\033[1;31m\]@\[\033[1;32m\]\h:\[\033[1;35m\]\w\[\033[1;31m\]\$\[\033[0m\] '

Exit & Login again to see the effect.

~ exit
~ ssh root@

Step 3 Install Apache

If this step you got error, you can read at More detail

~ sudo apt update
~ sudo apt install apache2

Check the version

~ apache2 -version

Check status of Apache

~ sudo systemctl status apache2

Check IP

~ hostname -I

Verifying that the Apache server is working properly. (Replace with your IP)


Step 4: Install PHP 7.2

More detail

~ sudo apt install php libapache2-mod-php

Testing PHP: Edit the file info.php

vi /var/www/html/info.php

With this content:


View the content:

cat /var/www/html/info.php

Verifing that the PHP works:


Step 5 Install MySQL

More Detail

Install mysql:

~ sudo apt install mysql-server

Verifing mysql:

~ sudo systemctl status mysql

Press ‘q’ to quit

Securing Mysql:

sudo mysql_secure_installation

=> Setup root password: 0 = LOW username: root password: your_root_pass

I choose ‘yes’ for all the questions

Verifing: Try to login and show database

~/sudo mysql
mysql> show databases;
mysql> exit;

Step 6: Enable mysql to apache

More detail

Install mysql lib:

~ apt-get update
~ apt-get install php7.2-mysql
~ apt-get install php-mysql


~ apt-cache search mysql

Restart apache

systemctl restart apache2.service

STEP 7: Install PHPMyAdmin

More detail


$ sudo apt-get update
$ sudo apt-get install phpmyadmin php-mbstring php-gettext

=> Select: apache2 > OK => Yes (Configure db for phpmyadmin)

Configure db for phpmyadmin with: ‘yes’

Write down your password: your_password (username:phpmyadmin)

Config FOR phpmyadmin

Read more if you got bug.

~ sudo mysql
mysql> GRANT ALL PRIVILEGES ON *.* TO 'phpmyadmin'@'localhost' WITH GRANT OPTION;

Test user: phpmyadmin pass: your_password

Create a test database: wp_example

More: (?)

$ sudo phpenmod mcrypt
$ sudo phpenmod mbstring

Step 8 : Add domain to droplet.

Follow this Link to add your domain to this droplet.

Add: Wait for server hours and try:

Add you domain

Step 9 : Install WordPress

If you dont need wordpress site. You can skip this step.

Download wordpress to server. Unzip it to public folder && grant permission for www-data

~ wget
~ tar -xf ./latest.tar.gz
~ mv ./wordpress/*  /var/www/html/
~ cd /var/www/html && chown -R www-data:www-data ./ ./*
~ rm -rf /var/www/html/index.html

Open: To Install your website with the username & password above (phpmyadmin or root are also ok)

Step 10: Setup Ssl for your site

For more detail


~ sudo apt-get install certbot python-certbot-apache
~ sudo certbot --apache

Select (A) Select (Y) Type your domain name: Select: 2 - For Redirect …


Go to WordPress’s Admin panel > Setting: WordPress Address (URL): Site Address (URL): =>Click ‘Save changes’ Button


If this link is auto to redirect to, you are DONE.

Step 11: Setup the second site.

  • Add domain to droplet:

  • Change DNS to:

  • Create the public folder & index file. Change the owner for it

Create the below folder:

|   |__ public_html

vi /var/www/

Hello from
cat /var/www/

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

Set config for apache:

vi /etc/apache2/sites-available/

With this content:

<VirtualHost *:80>
    DocumentRoot /var/www/

    <Directory /var/www/>
        Options -Indexes +FollowSymLinks
        AllowOverride All

    ErrorLog ${APACHE_LOG_DIR}/
    CustomLog ${APACHE_LOG_DIR}/ combined
cat /etc/apache2/sites-available/
~ sudo a2ensite
~ systemctl reload apache2

Enable Ssl for the site

(Same as above step)

~ sudo certbot --apache

Select (A) Select (Y) Follow the instructions. Select: 2 - For Redirect …

Profile picture

written by boy-Over-9
Eat, sleep, code, Judo repeat... Twitter