dotlinux blog

Install and Configure Web Services (Apache Virtual Hosting) on Zentyal Server

Zentyal Server is a powerful open-source server solution that offers a wide range of services. In this blog post, we'll focus on installing and configuring web services using Apache Virtual Hosting on Zentyal Server. This setup allows you to host multiple websites on a single server, each with its own domain name and configuration. Whether you're a developer looking to test multiple web applications or a small business owner wanting to manage multiple online presences, this guide will walk you through the process step by step.

2026-06

Table of Content#

  1. Prerequisites
    • Zentyal Server Installation
    • Domain Names and DNS Configuration
  2. Installing Apache Web Server
    • Using Zentyal's Package Manager
  3. Configuring Apache Virtual Hosting
    • Creating Virtual Host Directories
    • Editing the Apache Configuration File
    • Enabling the Virtual Host
  4. Testing the Setup
    • Checking Apache Configuration
    • Accessing the Websites

Prerequisites#

Zentyal Server Installation#

Before you can start with web services configuration, you need to have Zentyal Server installed on your server hardware. You can download the installation media from the official Zentyal website (https://www.zentyal.org/download/) and follow the on - screen installation wizard. Make sure your server meets the minimum system requirements (e.g., sufficient disk space, memory, etc.).

Domain Names and DNS Configuration#

You should have at least one domain name (or multiple if you plan to host multiple sites) registered. Also, configure your DNS (Domain Name System) records. For each domain you want to use with your virtual hosts, you need to create an A record that points to the IP address of your Zentyal Server. For example, if your server's IP is 192.168.1.100 and your domain is example.com, create an A record for example.com with the value 192.168.1.100. If you have sub - domains like blog.example.com, create an A record for that as well.

Installing Apache Web Server#

Using Zentyal's Package Manager#

Zentyal Server comes with a package manager that simplifies the installation of software. Log in to your Zentyal Server's web interface (usually at https://your_server_ip:8443). Navigate to the "Software" section. In the search bar, type "apache2". You should see the Apache HTTP Server package listed. Click on the "Install" button next to it. Zentyal will then download and install the necessary packages for Apache.

Configuring Apache Virtual Hosting#

Creating Virtual Host Directories#

  1. For a Single Site (e.g., example.com):
    • Log in to your Zentyal Server via SSH (using a tool like PuTTY on Windows or the terminal on Linux/macOS).
    • Create a directory for your website's files. For example, if your domain is example.com, you can create a directory like /var/www/example.com. Use the command sudo mkdir -p /var/www/example.com.
    • Set the appropriate permissions. You can use sudo chown -R www-data:www-data /var/www/example.com (where www-data is the user and group that Apache runs as). And sudo chmod -R 755 /var/www/example.com to give read and execute permissions to others.
  2. For Multiple Sites (e.g., example.com and blog.example.com):
    • Repeat the above steps for each domain. So, create /var/www/blog.example.com for the blog.example.com domain.

Editing the Apache Configuration File#

  1. For example.com:
    • Open the Apache configuration file for the virtual host. Create a new file in the /etc/apache2/sites-available/ directory. For example.com, use sudo nano /etc/apache2/sites-available/example.com.conf.
    • Add the following basic configuration:
<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example.com
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
- `ServerAdmin` is the email address for administrative contact. `ServerName` is the main domain name. `ServerAlias` can be used for additional domain names (like `www` sub - domain). `DocumentRoot` points to the directory where your website files are stored. `ErrorLog` and `CustomLog` define the log files.

2. For blog.example.com: - Create a new file /etc/apache2/sites-available/blog.example.com.conf using sudo nano /etc/apache2/sites-available/blog.example.com.conf. - Add the following:

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName blog.example.com
    DocumentRoot /var/www/blog.example.com
    ErrorLog ${APACHE_LOG_DIR}/blog_error.log
    CustomLog ${APACHE_LOG_DIR}/blog_access.log combined
</VirtualHost>

Enabling the Virtual Host#

  1. For example.com:
    • Enable the virtual host using the command sudo a2ensite example.com.conf.
  2. For blog.example.com:
    • Similarly, use sudo a2ensite blog.example.com.conf.
    • After enabling the virtual hosts, you need to restart Apache for the changes to take effect. Use the command sudo service apache2 restart.

Testing the Setup#

Checking Apache Configuration#

  1. Syntax Check:
    • Before restarting Apache (if you haven't already), you can check the syntax of your configuration files. Use the command sudo apache2ctl configtest. If there are no errors, you should see a message like Syntax OK.
  2. Log Files:
    • Check the error logs (e.g., /var/log/apache2/error.log for the main site and /var/log/apache2/blog_error.log for the blog site) if you encounter any issues. The logs can give you clues about what's wrong, such as permission errors or misconfigured directives.

Accessing the Websites#

  1. For example.com:
    • Open a web browser and type http://example.com (or http://www.example.com if you have set up the ServerAlias). You should see the default page (if you haven't added any custom content yet) or your custom website if you've uploaded files to the DocumentRoot directory.
  2. For blog.example.com:
    • Type http://blog.example.com in the browser. Again, you should see the appropriate content based on what's in the DocumentRoot directory for that virtual host.

Reference#