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 example.com. for the same we need a root directory for the website , let it be /var/www/example.com/

Create directory

sudo mkdir /var/www/example.com/

Now create new virtual host file at /etc/apache2/sites-available/example.com.conf:

sudo vi /etc/apache2/sites-available/example.com.conf

for you to copy use the below code assuming said directories

ServerAdmin admin@example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/
ErrorLog /var/www/example.com/error.log
CustomLog /var/www/example.com/access.log combined

Save and close the file

Enable the site with a2ensite:

$ sudo a2ensite example.com.conf

Disable the default site on server

$ sudo a2dissite 000-default.conf

Lets test site

$ sudo apache2ctl configtest

You should see the following output:

Output
Syntax OK
Restart Apache

$ sudo systemctl restart apache2

Add a Comment

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