Skip to content

Wealthiscertain/Manual-Guide--Hosting-a-Website-on-a-CentOS-VM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 

Repository files navigation

Manual-Guide-Hosting-a-Website-on-a-CentOS-VM

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-vms directory and create a new directory named finance using the command mkdir finance.

    image

  • Initialize Vagrant in this directory with: vagrant init eurolinux-vagrant/centos-stream-9.

    image

2. Configure the Vagrantfile

  • Open the Vagrantfile in the finance directory with vim Vagrantfile.

    image

  • Press i to enter insert mode, then uncomment and modify the lines for the IP address and memory size. Change the IP from 192.168.33.10 to 192.168.56.22.

Before

image

After

image

  • Press esc button on your PC to switch back to command mode.
  • Type :wq to save and exit the file.

3. Launch the VM

  • Start the VM with the command vagrant up.

    image

  • Once the VM is up, log in to the VM with the vagrant ssh command.

    image

  • Switch to the root user by running sudo -i.

    image

4. Update the VM Hostname

  • Change the hostname by editing the /etc/hostname file with vi /etc/hostname.

  • vi: is the default editor that comes with the LINUX operating system.

    image

  • Once the editor is up, type the new name, and type :wq to save and exit the vim editor.

    image

  • 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.

    image

7. Start the httpd Service

  • Start and enable the httpd service with the following commands:

    • systemctl start httpd
    • systemctl enable httpd

    image

8. Check the VM's IP Address

  • Verify the IP address with ip addr show.

    image

  • Test access by navigating to http://192.168.56.22/ in your web browser.

    image

9. Download an HTML Template

  • Select a free HTML website template from [tooplate.com], For this project, I chose the Mini finance template.

    image

  • Copy the download link from the browser's developer tools (F12).

    image

    image

10. Download and Extract the Template

  • Navigate to the HTML folder with cd var/www/html/

  • Navigate to the directory to the tmp directory with cd /tmp/

  • Download the template using wget https://www.tooplate.com/zip-templates/2135_mini_finance.zip

    image

  • Unzip the downloaded file with unzip 2135_mini_finance.zip

    image

  • Confirm operation was successful

    image

11. Deploy the Template to the Web Server

  • Use command cd 2135_mini_finance to 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

    image

12. Restart the httpd Service

  • Ensure the httpd service 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.

image

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published