Setting Up Virtual Hosts in Webmin
Prerequisites:
- A Linux server with Webmin installed. If you haven't installed Webmin, you can do so by following the official documentation for your Linux distribution.
- A registered domain name or access to a DNS server to configure domain records.
Step 1: Log in to Webmin
Open your web browser and navigate to your Webmin control panel. Typically, you can access it by entering https://your-server-ip:10000
in your browser. Replace your-server-ip
with the actual IP address of your server.
Log in with your administrator username and password.
Step 2: Install Apache Web Server Module
- Click on "Webmin" in the top-left corner to go back to the Webmin dashboard.
- In the left menu, navigate to "Servers" and click on "Apache Webserver."
- If the Apache Webserver module is not installed, you can install it by clicking on the "Module Config" link. Select the "Install Module" tab, search for "Apache Webserver," and click "Install Now."
- Once the module is installed, click "Return to Modules" and then "Apache Webserver" to access the Apache configuration.
Step 3: Create a New Virtual Host
- In the Apache Webserver module, click on "Create Virtual Host."
- Fill in the following information:
- Port: Leave it as "Any" for HTTP (port 80) or choose "SSL" for HTTPS (port 443).
- Document Root: The directory where your website files will be stored (e.g.,
/var/www/example.com/public_html
). - Server Name: The domain or subdomain you want to host (e.g.,
example.com
). - Server Aliases: Additional domains or subdomains pointing to the same virtual host (optional).
- Email Address: Your contact email address (optional).
- Click "Create."
Step 4: Configure DNS Records
To make your virtual host accessible via the domain name you specified, you need to configure DNS records. This step involves accessing your domain registrar or DNS provider's control panel and creating DNS records like A or CNAME records that point to your server's IP address.
For example, if you're hosting example.com
, you would create an A record pointing to your server's IP address.
Step 5: Test Your Virtual Host
- After configuring DNS records and allowing some time for DNS propagation (usually a few hours), you can test your virtual host.
- Open a web browser and enter your domain name (e.g.,
http://example.com
). - If everything is set up correctly, you should see your website.
Step 6: Configure Additional Virtual Hosts (Optional)
Repeat the process described in Step 3 to create additional virtual hosts for other websites or applications on the same server.
Step 7: Manage Virtual Hosts
You can manage your virtual hosts using Webmin's Apache Webserver module. You can edit, delete, or disable virtual hosts as needed.
Congratulations! You have successfully set up virtual hosts in Webmin to host multiple websites on your Linux server. Remember to keep your server and software updated, and regularly back up your website files and configuration.