Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

To host several domains on one Debian VPS, point each domain’s DNS records to the server, create one Apache virtual-host file per site in /etc/apache2/sites-available/, enable each file with a2ensite, validate the configuration, and reload Apache. Each host needs a ServerName and DocumentRoot; add ServerAlias for names such as www.

The procedure below starts with HTTP on port 80. HTTPS is a separate port-443 configuration that requires certificates; Apache uses SNI to select among multiple HTTPS sites.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What an Apache virtual host does

A name-based virtual host lets several domains share one VPS IP address and TCP port. The browser sends the requested hostname in the HTTP request, and Apache matches that hostname to a ServerName or ServerAlias in its configured virtual hosts. The matching block supplies the document root, logs, access rules, and any application-specific settings.

Debian separates site definitions from enabled sites:

#1 Best Overall
Sale
Compressed Air Duster,130000RPM Super Power Cordless Air Duster,Rechargeable Brushless Blower,3 Gear Adjustable Blower with LED Light,Dust Remover for Computer/House/Outdoor/Car
  • Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
  • With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
  • Wide Application: attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
  • Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
  • Economical &Reusable: Built durable materials with a long-lasting battery,our CAGIWIRU air duster it's a sustainable alternative to disposable air cans.
  • /etc/apache2/sites-available/ stores configuration files, whether or not they are active.
  • /etc/apache2/sites-enabled/ contains symbolic links for the sites Apache should load.

The a2ensite helper creates an enabled-site symlink; a2dissite removes that symlink without deleting the original file. This makes it possible to keep a configuration available while taking it out of service.

Apache also has a default host for requests that do not match any configured name. The first enabled virtual host for an address and port becomes that fallback, so the enabled-file order is operationally important.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Before you begin

Confirm administrative access

Run the commands with an account authorized to administer the VPS, normally through sudo. You need permission to install packages, write under /etc/apache2 and /var/www, manage the Apache service, and edit DNS at your domain provider.

Choose the names and paths

This guide uses example.com and www.example.com. Replace them with the real hostnames, but keep a consistent directory and log naming scheme. The example document root is /var/www/example.com/public_html.

Plan the DNS records

Every hostname that should reach the site must resolve to the VPS. Create an A record for an IPv4 address and, when the server is configured for IPv6, an AAAA record for its IPv6 address. DNS changes may take time to appear according to the records’ TTL, so do not diagnose Apache until you have checked what the public resolvers return.

Install Apache and verify the service

On a Debian VPS, install the distribution Apache package and check that the service is running:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo apt update
sudo apt install apache2
sudo systemctl status apache2

If the status command shows an inactive or failed service, inspect the service journal before adding sites:

sudo journalctl -u apache2

Fix an installation or startup problem first. A virtual-host file cannot be tested reliably while Apache itself is not healthy.

Rank #2
EVEO® Screen Cleaner Spray Kit (Streak-Free) TV Screen Cleaner for Smart TV, Lcd, LEd, Oled | Computer Screen Cleaner Spray and Wipe Microfiber Cloth - TV, Monitor, Laptop, iPad, Car - 6.7oz 1 Pack
  • Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
  • Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
  • Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
  • Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
  • Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth

Create a document root for each site

Create a separate directory for each domain. Keeping content separated prevents one site’s files from being accidentally served by another site and makes per-site permissions and backups easier to reason about.

sudo mkdir -p /var/www/example.com/public_html
sudo nano /var/www/example.com/public_html/index.html

Put a simple test page in index.html, such as a heading identifying example.com. Use ownership that fits the application: a static site can be readable by Apache without being writable by it, while an application with a controlled upload directory may need a narrower writable path. Do not make the entire document tree broadly writable just to resolve a permissions error.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Apache must be able to traverse every parent directory on the way to the document root. Check the execute permission on /var, /var/www, the domain directory, and public_html, as well as read permission on files. A 403 response can result from a parent directory that Apache cannot enter even when the final file looks readable.

Write the HTTP virtual-host file

Create one file in /etc/apache2/sites-available/ for the site:

sudo nano /etc/apache2/sites-available/example.com.conf

Use this minimal but operational configuration:

<VirtualHost *:80>
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example.com/public_html

    <Directory /var/www/example.com/public_html>
        Options FollowSymLinks
        AllowOverride None
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/example.com-error.log
    CustomLog ${APACHE_LOG_DIR}/example.com-access.log combined
</VirtualHost>

Understand each directive

  • <VirtualHost *:80> listens for HTTP traffic on port 80 on the server’s available addresses. The same address-and-port combination can have many name-based hosts.
  • ServerName is the primary hostname Apache uses for matching and for identifying the site in diagnostics.
  • ServerAlias adds alternate names. Add every hostname that should serve the same content, including a www name when that is part of your public URL.
  • DocumentRoot maps matching requests to files beneath the specified directory.
  • <Directory> applies filesystem access rules to that path. Require all granted allows Apache to serve it; adjust authorization for applications that need stricter controls.
  • Options FollowSymLinks permits symbolic links under this directory. Remove or change options that your application does not need.
  • AllowOverride None means Apache will not read per-directory .htaccess files there. If an application genuinely requires .htaccess, choose the narrowest AllowOverride setting that supports it instead of enabling every override category.
  • ErrorLog and CustomLog give the site its own error and access logs. The ${APACHE_LOG_DIR} variable follows Debian’s standard log directory.

The essential Apache requirements are the ServerName and DocumentRoot inside each virtual-host block. The directory and logging sections are practical additions that make permissions and diagnosis explicit.

Enable and disable sites safely

Enable the new configuration with Debian’s helper:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo a2ensite example.com.conf

The command creates the corresponding link in /etc/apache2/sites-enabled/. It does not replace the source file in sites-available. Disable the stock site when you have decided which host should handle unmatched requests:

sudo a2dissite 000-default.conf

Do not disable the only useful fallback accidentally. If a request arrives with an unknown or misspelled hostname, Apache will still send it to whichever host is first for that address and port. You can deliberately configure a catch-all site with a neutral response, or keep a known site as the fallback, but make that behavior an explicit decision.

Rank #3
Sale
BladeHawks RGB Gaming Mouse Pad Extra Large Extended 31.5x12 Inch-Black | LED mouse pad with 14 lighting modes, covers keyboard & mouse, anti-slip rubber base, waterproof surface, USB powered
  • 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
  • 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
  • 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
  • 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
  • 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.

Check the enabled-file order

List the enabled directory when diagnosing unexpected fallback behavior:

ls -l /etc/apache2/sites-enabled/

Debian commonly uses numeric prefixes such as 000-default.conf to influence lexical load order. The names of the symlinks, not just the names of files in sites-available, determine what Apache reads first.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Validate before reloading

Always test syntax before asking the running service to load a change:

sudo apache2ctl configtest

A successful check normally prints Syntax OK. If it reports an error, correct the exact file and line named in the message, then run the test again. Common causes include a missing closing tag, a misspelled directive, an invalid path, or a module-dependent directive whose module is not enabled.

Use Apache’s virtual-host listing to see the parsed result, including the default host and the names attached to each address and port:

sudo apache2ctl -S

Confirm that example.com and www.example.com appear under the intended *:80 host and that the displayed default host is the one you planned.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

After a successful test, perform a graceful reload:

sudo systemctl reload apache2

A reload applies configuration changes while allowing existing connections to finish. If the service manager reports an error, inspect sudo journalctl -u apache2 and the relevant Apache error log before trying another reload.

Rank #4
Sale
Vaydeer Wrist Rest for Keyboard and Mouse, Computer Ergonomic Wrist Support Pad, Soft Memory Foam Arm Cushion for Desk, Palm Hand Office Laptop Typing
  • 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
  • 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
  • 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
  • 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
  • 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.

Point DNS at the VPS and test HTTP

Create the A and, where applicable, AAAA records for each hostname. Test what your resolver returns:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
dig example.com
 dig www.example.com
getent hosts example.com

Remove the leading space before dig if copying the second line; it is shown separately only to emphasize that each hostname should be checked. Compare the returned address with the VPS address. If the result is an old server, a private address, or no address, fix DNS before changing Apache.

Once resolution is correct, request only the headers first:

curl -I http://example.com
curl -I http://www.example.com

A response from the wrong site usually means the request reached Apache but did not match the host you expected. Check the exact hostname in the URL, the ServerName and ServerAlias spelling, the enabled links, and the output of apache2ctl -S. A direct test against the VPS address without the hostname does not exercise name-based selection and may intentionally return the fallback host.

Add HTTPS virtual hosts

HTTP configuration does not automatically provide HTTPS. For TLS, create a separate <VirtualHost *:443> block and use the certificate workflow you have selected to obtain and renew certificates. The block must reference the certificate and private-key files supplied by that workflow, for example:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example.com/public_html

    <Directory /var/www/example.com/public_html>
        Options FollowSymLinks
        AllowOverride None
        Require all granted
    </Directory>

    SSLEngine on
    SSLCertificateFile /etc/ssl/example.com/fullchain.pem
    SSLCertificateKeyFile /etc/ssl/example.com/privkey.pem

    ErrorLog ${APACHE_LOG_DIR}/example.com-ssl-error.log
    CustomLog ${APACHE_LOG_DIR}/example.com-ssl-access.log combined
</VirtualHost>
</IfModule>

The certificate paths above are an example layout; use the paths produced by your certificate manager. Enable the SSL module and the configuration needed by that workflow, then run apache2ctl configtest and reload Apache again. Keep private keys readable only by the accounts that need them.

Test both the HTTP and HTTPS names. If your policy is HTTPS-only, configure the port-80 host to redirect to the corresponding HTTPS URL after confirming that the TLS host works. Verify that the certificate’s subject alternative names cover every hostname you publish. Apache’s SNI support allows multiple HTTPS virtual hosts to share an address, provided the client sends the requested hostname and each host has suitable certificate coverage.

Keep logs useful as sites multiply

Per-host ErrorLog and CustomLog directives prevent unrelated applications from being mixed into one stream. They also make it easier to identify whether a failure occurred during request routing, authorization, or application execution.

Best Value
Sale
Under Desk Cable Management Tray No Drill, Metal Mesh Cable Management Under Desk with Clamp Mount, 2 Hole Cable Tray with Wire Management and Cord Organizer for Home Office Standing Desk
  • 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
  • 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
  • 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
  • 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
  • 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.

For a larger installation, a vhost-aware log format can retain host information in a shared log. Choose either clearly separated files or a shared format deliberately; mixing both without a naming convention makes incident analysis harder. When a request returns an unexpected page, inspect the access log for the received host and the error log for permission or filesystem messages.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Name-based and IP-based hosting compared

Hosting choice How Apache selects the site Address requirement When it fits
Name-based virtual hosting Matches the request hostname to ServerName or ServerAlias. Multiple names share one IP address and port. Most domains on a Debian VPS, especially when IPv4 addresses are limited.
IP-based hosting Uses a distinct local IP address for each host. Each site needs its own server address. Cases that require address-level separation or special networking constraints.
Port-based separation Uses different listening ports. Clients must request the nonstandard port. Internal services or deliberate service separation rather than ordinary public websites.

Name-based hosting is normally the simplest public arrangement, but it depends on correct DNS and the hostname being present in the request. IP- or port-based layouts do not remove the need for correct Apache configuration; they change the address-and-port combinations Apache evaluates.

HTTP-only versus HTTPS deployments

Deployment Configuration What to verify
HTTP only A <VirtualHost *:80> block with the site names and document root. DNS resolution, host matching, filesystem access, and HTTP responses.
HTTP plus HTTPS Port-80 and port-443 blocks, TLS module/configuration, and certificates for each published name. Certificate hostname coverage, SNI selection, HTTPS response, and any HTTP-to-HTTPS redirect.

Adding a certificate does not repair a wrong document root or a DNS record pointing elsewhere. Treat name resolution, Apache routing, filesystem authorization, and TLS as separate layers when troubleshooting.

Troubleshooting common failures

The wrong site appears

  1. Confirm the URL contains the hostname you configured, not only the VPS IP address.
  2. Resolve that hostname with dig or getent hosts and verify it reaches the VPS.
  3. Check that the spelling and capitalization-independent hostname values in ServerName and ServerAlias match the URL.
  4. Run sudo apache2ctl -S and confirm the expected host is parsed and enabled.
  5. Inspect the enabled-file order and the planned fallback for unmatched names.

If DNS is correct and the host is parsed, review the per-host access log to see which request arrived and which file was served.

Apache reports a syntax error

Run sudo apache2ctl configtest and correct the file and line named in its output. Do not reload while the test fails. Check matching opening and closing tags, directive spelling, certificate paths in TLS blocks, and whether a directive requires a module that is not enabled.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The response is 403 Forbidden

  • Verify that Apache can execute (traverse) every parent directory leading to the document root.
  • Check read permissions on the requested file and its containing directories.
  • Confirm the <Directory> path exactly matches DocumentRoot.
  • Review Require authorization directives and any application-specific access rules.
  • Read the site’s error log for the precise path and permission Apache rejected.

HTTPS shows a certificate mismatch

Check the hostname in the browser request, the matching *:443 virtual host, the certificate’s subject alternative names, and whether the client supports SNI. A certificate for example.com does not automatically cover www.example.com; both names must be included or served with certificates that cover them. Also verify that the certificate and key configured for the selected host belong together.

Logs are difficult to separate

Give each virtual host distinct ErrorLog and CustomLog paths, as in the example. If a shared log is required, use a vhost-aware LogFormat so the hostname is retained with each request. Confirm that the Apache service account can write to the chosen log location.

Reload fails after an otherwise successful edit

Run apache2ctl configtest again, inspect journalctl -u apache2, and read the relevant Apache error log. A configuration can pass a basic syntax check yet fail at service start if a referenced file is missing, a certificate cannot be read, or a required module is unavailable. Correct the reported dependency, validate again, and only then reload.

A repeatable workflow for additional domains

Once the first site works, repeat the same sequence for each domain rather than copying a live file and editing it in place without review:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Create a distinct document root and place a recognizable test page there.
  2. Set ownership and permissions appropriate to that site, including traversal rights on parent directories.
  3. Create a new file under /etc/apache2/sites-available/ with a unique ServerName, required aliases, document root, directory authorization, and logs.
  4. Enable it with sudo a2ensite site-name.conf.
  5. Run sudo apache2ctl configtest, then inspect sudo apache2ctl -S.
  6. Reload Apache with sudo systemctl reload apache2.
  7. Point DNS records to the VPS and verify them with dig or getent hosts.
  8. Test each hostname with curl -I and inspect that host’s logs.
  9. Add and test the corresponding port-443 host and certificate before redirecting HTTP traffic.

Pre-production checklist

  • Every published hostname has the intended A and/or AAAA record.
  • Each domain has its own document root and a test page was removed or replaced with application content.
  • Each HTTP block contains the correct ServerName and any required ServerAlias.
  • Every DocumentRoot has a matching, deliberate <Directory> policy.
  • Filesystem traversal and file-read permissions work for the Apache service account.
  • Each intended site is enabled, and the fallback host is intentional.
  • apache2ctl configtest returns Syntax OK.
  • apache2ctl -S shows the expected names, ports, and default host.
  • Apache was gracefully reloaded only after validation.
  • Per-host logs are present and readable by the administrators who will operate the sites.
  • Each HTTPS certificate covers all names users will enter, and both HTTPS routing and any redirect have been tested.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.