Tuesday, 22 September 2020

Host a website on Ubuntu on port 80

 Below are the steps to host a website on port 80. In the below example 172.16.1.11 is the IP adddress on the Ubuntu server which will receive the customer traffic.


STEP 1: Create a directory which will contain the HTML page of the website.

Sudo Su

mkdir /var/www/html/172.16.1.11_80


STEP 2:  Create the index html file and add the HTML code in it

nano /var/www/html/172.16.1.11_80/index.html

<html>

<title>172.16.1.11_80</title>

<h1>Welcome to 172.16.1.11_80 Website</h1>

<p>Website on port 80</p>

</html>

ctrl + X then press Y 

Press Enter


STEP 4:  Give Sufficient permission to the folder

chown -R www-data:www-data /var/www/html/172.16.1.11_80


STEP 5:   Add the website to the "SITES-AVAILABLE" FOLDER.

nano /etc/apache2/sites-available/172.16.1.11_80.conf

<VirtualHost 172.16.1.11:80>

ServerAdmin admin@localhost

ServerName  172.16.1.11

DocumentRoot /var/www/html/172.16.1.11_80

DirectoryIndex index.html

ErrorLog ${APACHE_LOG_DIR}/80_error.log

CustomLog ${APACHE_LOG_DIR}/80_access.log combined

</VirtualHost>

ctrl + X then press Y 

Press Enter


STEP 6:  Publish the website on Ubuntu

a2ensite 172.16.1.11_80


STEP 7:   Restart Apache service

systemctl restart apache2

No comments:

Post a Comment