In my previous article, I provided a Step-by-Step Guide to Creating a CentOS VM with Vagrant. In this post, I'll walk you through the process of hosting an HTML template on CentOS with the help of httpd on a Vagrant-managed VM.
Tools used
- Ready-made template: Free HTML website templates from [tooplate.com]
- Vagrant: Automates the creation and management of virtual environments.
- CentOS: A free, enterprise-class Linux distribution, ideal for server environments.
- Git Bash: A command-line tool that allows users to run Git commands and other Unix-based utilities on Windows.
Step-by-Step Setup
1. Create and Initialize a Vagrant Directory
-
Navigate to your
vagrant-vmsdirectory and create a new directory namedfinanceusing the commandmkdir finance. -
Initialize Vagrant in this directory with:
vagrant init eurolinux-vagrant/centos-stream-9.
2. Configure the Vagrantfile
-
Open the Vagrantfile in the
financedirectory withvim Vagrantfile. -
Press
ito enter insert mode, then uncomment and modify the lines for the IP address and memory size. Change the IP from192.168.33.10to192.168.56.22.
Before
After
- Press
escbutton on your PC to switch back tocommand mode. - Type
:wqto save and exit the file.
3. Launch the VM
-
Start the VM with the command
vagrant up. -
Once the VM is up, log in to the VM with the
vagrant sshcommand. -
Switch to the root user by running
sudo -i.
4. Update the VM Hostname
-
Change the hostname by editing the
/etc/hostnamefile withvi /etc/hostname. -
vi: is the default editor that comes with the LINUX operating system.
-
Once the editor is up, type the new name, and type
:wqto save and exit the vim editor. -
Apply the new hostname by running
hostname finance.
5. We will require the following packages:
- httpd: The package is needed to host websites on CentOS.
- wget: A tool for downloading files, such as HTML templates.
- vim: A text editor for modifying files.
- unzip: A utility for extracting files from ZIP archives.
6. Install necessary packages
-
Install the required packages using the command:
yum install httpd wget vim unzip zip -y. -
The complete message at the end signifies the installation was Successful.
7. Start the httpd Service
-
Start and enable the httpd service with the following commands:
systemctl start httpdsystemctl enable httpd
8. Check the VM's IP Address
-
Verify the IP address with
ip addr show. -
Test access by navigating to
http://192.168.56.22/in your web browser.
9. Download an HTML Template
-
Select a free HTML website template from [tooplate.com], For this project, I chose the Mini finance template.
-
Copy the download link from the browser's developer tools (F12).
10. Download and Extract the Template
-
Navigate to the HTML folder with
cd var/www/html/ -
Navigate to the directory to the
tmpdirectory withcd /tmp/ -
Download the template using
wget https://www.tooplate.com/zip-templates/2135_mini_finance.zip -
Unzip the downloaded file with
unzip 2135_mini_finance.zip -
Confirm operation was successful
11. Deploy the Template to the Web Server
-
Use command
cd 2135_mini_financeto navigate to the HTML template directory -
Copy the template files to the web server's root directory with
cp -r * /var/www/html/ -
Confirm copy was successful
12. Restart the httpd Service
- Ensure the
httpdservice is running smoothly by restarting it and checking its status: -systemctl start httpd-systemctl status httpd
13. Verify the Website
Visit http://192.168.56.22/ in your browser to confirm the website is up and running.





















