Skip to content

Virtual hosting in Red Hat (or any Linux-based system) refers to hosting multiple websites or domains on a single server. This can be achieved using Apache HTTP Server (commonly known as Apache)

Notifications You must be signed in to change notification settings

panwar100/virtual-hosting-in-linux

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

virtual-hosting-in-linux

Virtual hosting in Red Hat (or any Linux-based system) refers to hosting multiple websites or domains on a single server. This can be achieved using Apache HTTP Server (commonly known as Apache) or NGINX. Below is a guide to set up virtual hosting in Apache on a Red Hat-based system like RHEL.

Steps to Set Up Virtual Hosting in Apache on Red Hat:

1. Install Apache

Ensure Apache is installed on your RHEL system. If not, install it using:

Screenshot from 2024-12-25 00-04-23

2. Enable and Start Apache

Enable and start the Apache service to ensure it runs at startup.

Screenshot from 2024-12-25 00-19-11

3. Configure the Virtual Host Files

Apache uses virtual host configuration files to manage multiple sites.

Example Configuration for Two Sites:

  • Create directories for the websites:

Screenshot from 2024-12-25 00-26-56


  • Set permissions:

Screenshot from 2024-12-25 00-27-53


  • Add test content:

Site1

Screenshot from 2024-12-25 00-30-47

Screenshot from 2024-12-25 00-35-51


Site2

Screenshot from 2024-12-25 00-34-22

Screenshot from 2024-12-25 00-33-39


  • Create virtual host configuration files: Virtual host files are stored in /etc/httpd/conf.d/.

Virtual Host : Create a file named vhost.conf

Screenshot from 2024-12-25 00-47-18

Add the following configuration:

Screenshot from 2024-12-25 00-56-21

4. Update the hosts File (For Testing Locally)

To test locally without DNS setup, update the /etc/hosts file:

Screenshot from 2024-12-25 01-18-56

Add entries for your test domains:

Screenshot from 2024-12-25 00-53-00

5. Restart Apache

After making these changes, restart Apache to apply the configurations:

Screenshot from 2024-12-25 01-14-42

6. Test the Configuration

Open a web browser and navigate to:

Screenshot from 2024-12-25 01-02-49

Screenshot from 2024-12-25 01-03-43

Troubleshooting Tips

  • Check Apache Syntax: Before restarting Apache, check for configuration errors:

Screenshot from 2024-12-25 01-05-24

  • Check Logs: If there are issues, check the Apache logs for errors:

    sudo tail -f /var/log/httpd/error_log
    
  • Firewall Configuration: Ensure the firewall allows HTTP traffic:

Screenshot from 2024-12-25 01-00-02


This setup enables you to host multiple websites on a single Red Hat server using Apache.

About

Virtual hosting in Red Hat (or any Linux-based system) refers to hosting multiple websites or domains on a single server. This can be achieved using Apache HTTP Server (commonly known as Apache)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published