Establish Your Digital Presence: Deploying Your First Website on a Virtual Machine - Day 14/90

Establish Your Digital Presence: Deploying Your First Website on a Virtual Machine - Day 14/90

Β·

4 min read

In this guide, I'll take you through the process of deploying your first website on a virtual machine, making it accessible to the world. So, let's dive in! πŸš€

Note - I will be using Vagrant to setup the VM, so if you haven't installed vagrant please check out my previous article on hashnode.

You can also continue without vagrant just make sure you configure public and private networks properly.

Step 1:Choosing the Right Templateβœ…

Before you can begin hosting your website, you'll need a template to serve as the foundation for your site. To make this process easy and efficient, head over to tooplate.com and explore their wide range of templates. Tooplate offers a variety of stylish, user-friendly templates to suit your specific needs. πŸ“œπŸ’Ό

I have chosen this coffee template and copied the download link because we are going to download this template on our virtual machine

Step 2:Setting Up a Fresh Virtual Machine πŸ’»

πŸ’‘
I will be using CentOs virtual machine for setting up this mini-project.

Made network configuration in vagrant file.

Step 3:Installing Dependencies πŸ“‚

To ensure your website runs smoothly, you need to install essential dependencies. Here's how you can do it:

Installing Apache2

Apache2 is one of the most popular web servers globally, known for its reliability and performance. To install Apache2, open a terminal and use the following commands:

For Ubuntu users

sudo apt update
sudo apt install apache2 -y

For Red Hat or CentOS users:

sudo yum install httpd -y

Installing Unzip

In most cases, you'll need to unzip files for your website. To install the 'unzip' utility, use the following commands:

sudo apt install unzip

For Red Hat or CentOS users:

sudo yum install unzip

Step 4: Downloading and setting up template

Extracting the zip file of the template.

Unzipping files to /var/www/html directory, because this directory is used to server the HTML content on the internet i.e. webpage.

Step 5:Managing the Apache2 Service πŸ”§

Once Apache2 is installed, you need to know how to manage it effectively. Here are some basic commands:

Started the httpd service.

Enabled the httpd service so that it initialize when the vm in booted.

  • Start Apache2: To start the Apache2 service, use this command for Ubuntu:

      sudo systemctl start apache2
    

    For Red Hat or CentOS users:

      sudo systemctl start httpd
    
  • Stop Apache2: If you need to stop the Apache2 service, use this command for Ubuntu:

      sudo systemctl stop apache2
    

    For Red Hat or CentOS users:

      sudo systemctl stop httpd
    
  • Restart Apache2: To restart the Apache2 service after making configuration changes, use this command for Ubuntu:

      sudo systemctl restart apache2
    

    For Red Hat or CentOS users:

      sudo systemctl restart httpd
    

Disabling Firewall (For Red Hat or Ubuntu VMs)

Security is crucial, but sometimes you might need to disable the firewall temporarily to ensure that your website is accessible. Here's how to do it:

For Red Hat/CentOS Users

  1. Check the Firewall Status:

     sudo systemctl status firewalld
    
  2. Disable the Firewall:

     sudo systemctl stop firewalld
    
  3. Permanently Disable Firewall on Boot:

     sudo systemctl disable firewalld
    

For Ubuntu Users

  1. Check the Firewall Status:

     sudo ufw status
    
  2. Disable the Firewall:

     sudo ufw disable
    
  3. Enable the Firewall (after your website is up and running):

     sudo ufw enable
    

Final Results

I tried hitting the ip address which I had configured during the creation of vm. And it works.

Conclusion

Congratulations! You've successfully deployed your first website on a virtual machine. You've learned how to choose the right template, set up a fresh virtual machine, install essential dependencies, manage the Apache2 (httpd) service, and, if necessary, disable the firewall. Your website is now ready to be accessed by users worldwide.

Remember that hosting a website is a continuous process, and you can always fine-tune and enhance your website's performance as you go. Don't forget to keep your content fresh and engaging to attract and retain visitors. Happy web hosting! πŸš€πŸŒπŸŽ‰

Now that you have the basic steps, you can start building and customizing your website to make it truly unique and engaging. πŸŒŸπŸŽ¨πŸ’‘

Did you find this article valuable?

Support 90 days of Devops by becoming a sponsor. Any amount is appreciated!

Β