Create a Webiste on DigitalOcean Droplet with Ubuntu OS

First you go and create your Droplet with DigitalOcean

Once you logged in to your dropplet with SSH , Update repository database

$ sudo apt update

Now Install the apache2 package:

$ sudo apt install apache2

Check Apache Status

$ sudo systemctl status apache2

Now we are about to create a website , say for the same we need a root directory for the website , let it be /var/www/

Create directory

sudo mkdir /var/www/

Now create new virtual host file at /etc/apache2/sites-available/

sudo vi /etc/apache2/sites-available/

for you to copy use the below code assuming said directories

DocumentRoot /var/www/
ErrorLog /var/www/
CustomLog /var/www/ combined

Save and close the file

Enable the site with a2ensite:

$ sudo a2ensite

Disable the default site on server

$ sudo a2dissite 000-default.conf

Lets test site

$ sudo apache2ctl configtest

You should see the following output:

Syntax OK
Restart Apache

$ sudo systemctl restart apache2

Add a Comment

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