Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk12 min

How to Host Two Domains on One VPS Without a Control Panel

A practical, control-panel-free guide to serving two domains from one VPS using DNS, Nginx or Apache name-based hosting, isolated document roots and Certbot TLS.

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.

Yes—you can host two completely separate websites on one VPS and one public IP without installing a control panel. Point both domains to the VPS with DNS, then configure either Nginx server blocks or Apache name-based virtual hosts. Give each hostname its own document root, logs and application settings, test the configuration, reload the web server, and issue HTTPS certificates after public DNS resolves.

How two domains share one VPS

A browser sends a request to the VPS address with a hostname such as example-one.com in the HTTP Host header. Nginx or Apache compares that hostname with its configured names and selects the matching site definition. Each definition can point to a different directory, runtime, reverse-proxy upstream and log files.

As an Amazon Associate I earn from qualifying purchases.

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

This is called name-based virtual hosting. The same public IPv4 address can therefore serve both domains; a second IP address is not required. HTTPS adds the same hostname-selection idea during the TLS handshake through SNI, allowing the server to present the certificate for the requested domain.

DNS and web-server configuration are separate tasks. A server block or VirtualHost does not create DNS records, and a DNS record does not tell the web server which directory to use. Both layers must be correct.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

Prerequisites and decisions

  • A VPS with a public IPv4 address. Add an IPv6 address only if you will publish an AAAA record and have configured IPv6 firewall access.
  • Administrative SSH access and a supported Linux distribution. The commands below use Debian/Ubuntu-style package and service names.
  • Two registered domains, for example example-one.com and example-two.com.
  • A choice of web server: Nginx is commonly used for lightweight static serving and reverse-proxying; Apache has a mature module and per-directory configuration model.
  • A plan for each site’s application user, deployment process, data directory and backups. Do not let one site’s writable directories overlap the other site’s.

Decide whether the www hostname will be an alias, a redirect or a separate application. Include every hostname that should work in the server configuration and in the TLS certificate request.

Step 1: Point both domains at the VPS

Create the DNS records

At the authoritative DNS provider, create an A record for each apex domain:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Record Name Value Purpose
A @ (or the provider’s apex notation) VPS public IPv4 address Routes example-one.com or example-two.com to the server
A www VPS public IPv4 address, or an appropriate CNAME Routes the www hostname
AAAA @ and, if used, www VPS public IPv6 address Publishes IPv6 service; add only when IPv6 is working end to end

Replace the names with the records for both domains. Remove stale A or AAAA records that point to an old host. An incorrect AAAA record can make IPv6-capable visitors reach a different machine even when the A record is correct.

Check resolution before configuring certificates

Query public DNS from a workstation or another network:

dig +short example-one.com A
dig +short www.example-one.com A
dig +short example-two.com A
dig +short www.example-two.com A
dig +short example-one.com AAAA

The returned addresses should match the VPS addresses you intend to use. DNS changes can be cached according to the records’ TTL, so a local resolver may continue returning an old value for a while. Do not request an HTTP-01 certificate until the public Internet reaches this VPS on port 80.

Option A: Configure two Nginx sites

Install Nginx and create isolated roots

sudo apt update
sudo apt install nginx
sudo mkdir -p /var/www/example-one /var/www/example-two
sudo chown -R $USER:$USER /var/www/example-one /var/www/example-two
sudo chmod 755 /var/www/example-one /var/www/example-two

The ownership shown is suitable for creating test files as your administrative user. For a production application, use a dedicated deployment account and grant the web-service account only the read, execute or upload permissions it actually needs. Never make an entire site tree world-writable.

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.

Create a distinct test page in each root so that routing errors are obvious:

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.
printf '%sn' 'example-one site' > /var/www/example-one/index.html
printf '%sn' 'example-two site' > /var/www/example-two/index.html

Write one server block per domain

Ubuntu-style Nginx installations keep site files in /etc/nginx/sites-available/ and activate them with symlinks in /etc/nginx/sites-enabled/. Create the first file:

sudo nano /etc/nginx/sites-available/example-one
server {
    listen 80;
    listen [::]:80;
    server_name example-one.com www.example-one.com;

    root /var/www/example-one;
    index index.html index.php;

    access_log /var/log/nginx/example-one.access.log;
    error_log  /var/log/nginx/example-one.error.log;
}

Create the second file with a different server_name, root and log names:

sudo nano /etc/nginx/sites-available/example-two
server {
    listen 80;
    listen [::]:80;
    server_name example-two.com www.example-two.com;

    root /var/www/example-two;
    index index.html index.php;

    access_log /var/log/nginx/example-two.access.log;
    error_log  /var/log/nginx/example-two.error.log;
}

The IPv6 listen line is appropriate only when the VPS is configured for IPv6. If it is not, omit that line and do not publish AAAA records.

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

Enable, test and reload

sudo ln -s /etc/nginx/sites-available/example-one /etc/nginx/sites-enabled/example-one
sudo ln -s /etc/nginx/sites-available/example-two /etc/nginx/sites-enabled/example-two
sudo nginx -t
sudo systemctl reload nginx

nginx -t must report a successful syntax test before you reload. A reload keeps existing connections while applying the new configuration. If the distribution’s default site catches unmatched requests, either leave it as an intentional fallback or disable it after confirming that no required service depends on it:

sudo rm /etc/nginx/sites-enabled/default
sudo nginx -t
sudo systemctl reload nginx

Do not remove a default configuration blindly on a managed image; inspect it first and preserve an explicit fallback if you want unmatched hostnames to receive a known response.

Proxy an application instead of serving files

If a site runs a separate application process, keep its upstream port private and add a location to that site’s block. For example:

location / {
    proxy_pass http://127.0.0.1:3001;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
}

Use a different localhost port or Unix socket for the second application. Keep each process supervised independently so restarting one site does not stop the other. If you use PHP, configure the appropriate PHP-FPM socket or upstream for each application rather than exposing a backend port publicly.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by

Option B: Configure two Apache VirtualHosts

Install Apache and prepare roots

sudo apt update
sudo apt install apache2
sudo mkdir -p /var/www/example-one /var/www/example-two
sudo chown -R $USER:$USER /var/www/example-one /var/www/example-two
sudo chmod 755 /var/www/example-one /var/www/example-two
printf '%sn' 'example-one site' > /var/www/example-one/index.html
printf '%sn' 'example-two site' > /var/www/example-two/index.html

Apache’s service account must be able to traverse the directory path and read the files. For an application that needs uploads or generated cache files, grant write access only to those specific directories.

Create one VirtualHost file for each site

Put the first definition in /etc/apache2/sites-available/example-one.conf:

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

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

Create /etc/apache2/sites-available/example-two.conf:

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

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

ServerName is the primary hostname; add every alternate name as a ServerAlias. Keeping separate logs makes it possible to diagnose one site’s permissions or application errors without filtering a combined file.

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

Enable, validate and reload Apache

sudo a2ensite example-one.conf
sudo a2ensite example-two.conf
sudo apache2ctl configtest
sudo systemctl reload apache2

The configuration test should return Syntax OK. If the stock default site is still enabled, it may answer requests whose host header does not match either definition. You can disable it after checking that it is not needed:

sudo a2dissite 000-default.conf
sudo apache2ctl configtest
sudo systemctl reload apache2

Apache serves an unmatched request from the first/default VirtualHost for the address and port. Treat that behavior deliberately: a simple static fallback page is safer than accidentally exposing a private site’s content.

Use Apache as a reverse proxy

For an application server, enable the required proxy modules and add a separate proxy definition inside the relevant VirtualHost. A minimal pattern is:

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.
sudo a2enmod proxy proxy_http headers
sudo systemctl reload apache2
ProxyPreserveHost On
ProxyPass        / http://127.0.0.1:3002/
ProxyPassReverse / http://127.0.0.1:3002/

Give the second domain a different backend port or socket. Confirm that the application trusts the forwarded scheme and host headers only from your web server.

How to verify HTTP routing

  1. Check that each domain’s A and, when applicable, AAAA records return the VPS addresses.
  2. Confirm that the intended test file or application exists in each separate document root.
  3. Run sudo nginx -t for Nginx or sudo apache2ctl configtest for Apache.
  4. Reload the selected service and request each hostname explicitly: curl -i http://example-one.com/ and curl -i http://example-two.com/.
  5. Verify that the response body identifies the correct site and that the corresponding access log receives the request.
  6. Test an unknown hostname and decide whether the intentional default site, a refusal or a redirect is the desired result.

Before DNS has propagated, you can test routing against the VPS address while supplying the host header:

curl -i --resolve example-one.com:80:203.0.113.10 http://example-one.com/
curl -i --resolve example-two.com:80:203.0.113.10 http://example-two.com/

Replace 203.0.113.10 with the VPS address. The --resolve option changes where curl connects while preserving the hostname used for HTTP routing.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Add HTTPS with Certbot

Use HTTP-01 for ordinary certificates

After both domains resolve publicly and port 80 is reachable through the VPS firewall and any upstream firewall, install Certbot and its web-server plugin:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo apt install certbot python3-certbot-nginx

For an Nginx site, request one certificate containing both the apex and www names:

sudo certbot --nginx -d example-one.com -d www.example-one.com

For an Apache site, install the Apache plugin and request the second site’s certificate:

sudo apt install certbot python3-certbot-apache
sudo certbot --apache -d example-two.com -d www.example-two.com

Use the plugin that matches the server managing that site’s configuration. Certbot looks for the matching server block or VirtualHost, performs the validation and can add TLS directives and an HTTP-to-HTTPS redirect. Review the proposed changes rather than assuming a redirect is appropriate for every endpoint.

HTTP-01 validation requires the certificate authority to reach a challenge response on port 80 for each requested hostname. A certificate can contain multiple names as SANs, but every name must resolve to and validate against the server. Let’s Encrypt certificates are valid for 90 days, so leave the distribution’s renewal timer enabled and perform a renewal test before relying on it:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo certbot renew --dry-run

Inspect the installed certificate and confirm that its names include the hostname users will visit. Do not regard a successful command as proof that every alias is covered; read the certificate details and test each HTTPS name.

When DNS-01 is the better challenge

Use DNS-01 when port 80 cannot be exposed or when you need a wildcard certificate such as *.example-one.com. The challenge is a DNS TXT record rather than an HTTP file, so the DNS provider must support safe automation or you must create the record manually. Keep DNS API credentials restricted and do not publish them in application directories.

Firewall, permissions and isolation

  • Allow inbound TCP 80 and 443, plus SSH restricted to trusted source addresses where practical. Do not expose application ports such as 3001 or 3002 to the Internet when the web server can proxy them locally.
  • Use separate Unix users, virtual environments, containers or service units when the applications have different trust levels.
  • Keep deployment files, environment secrets, backups and database sockets outside public document roots.
  • Set ownership and mode bits so the web-service account can read public files but cannot modify the whole release tree.
  • Rotate and monitor each site’s access and error logs. Configure log retention so one high-traffic domain cannot fill the VPS disk used by the other.
  • Back up both site data and the Nginx or Apache configuration. A document root alone is not a complete restore; include database dumps, uploaded files, certificates or renewal configuration, systemd units and DNS record details.

Nginx or Apache: which fits two domains?

Concern Nginx Apache
Site definition One server block per hostname, commonly stored in sites-available and enabled through symlinks One <VirtualHost> block per address and port, commonly enabled with a2ensite
Routing mechanism server_name selects the matching block ServerName and ServerAlias select the matching VirtualHost
Static files and reverse proxy Direct static serving and reverse proxying are core, explicit configuration features Static serving is built in; reverse proxying uses modules such as proxy and proxy_http
Per-site logs Set access_log and error_log inside each server block Set ErrorLog and CustomLog inside each VirtualHost
Application compatibility Often placed in front of PHP-FPM or another application server Supports its own modules and application integration; per-directory rules may be useful
Certificate automation Certbot’s Nginx plugin can locate the server block and add TLS settings Certbot’s Apache plugin can locate the VirtualHost and add TLS settings
Best choice Choose it when your team prefers explicit centralized configuration and proxy-focused deployments Choose it when your team relies on Apache modules, existing VirtualHost files or per-directory behavior

Both servers support multiple names on one IP. Team familiarity, the application’s module requirements and your preferred deployment model are more important than the number of domains.

Troubleshooting by symptom

Both domains show the same website

  • Confirm that both requests include the expected hostname and that each name appears only in its intended server_name or ServerName/ServerAlias.
  • Check for a duplicate or overly broad wildcard name such as _ that is catching requests first.
  • Verify that the two roots or upstream ports are genuinely different.
  • Inspect each site’s access log while making a request; the log that receives the request identifies which definition matched.

A domain reaches the wrong server

Compare public A and AAAA answers with the VPS addresses. An old record, proxy service, or incorrect IPv6 route can bypass the VPS entirely. Test with dig from more than one network after the DNS TTL has elapsed.

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

Nginx refuses to reload

Run sudo nginx -t and read the file and line number in the error. Common causes include a missing semicolon, a duplicated listen directive with incompatible options, an unreadable included file or a typo in a path. Correct the file, rerun the test and reload only after it passes.

Apache reports a syntax error

Run sudo apache2ctl configtest. Check unmatched closing tags, misspelled directives, missing modules and log-directory permissions. Enable a required module with a2enmod, test again and reload.

HTTPS validation fails

  • Make sure every requested hostname resolves to this VPS, including www aliases.
  • Allow TCP 80 through the VPS and any external firewall for HTTP-01.
  • Ensure the web server is not redirecting or blocking the ACME challenge path.
  • Check that another server or stale default site is not answering the hostname.
  • Use DNS-01 instead when port 80 cannot be made reachable or a wildcard name is required.

HTTPS works for one name but not the other

Inspect the certificate’s Subject Alternative Name list and the TLS configuration selected for each hostname. Request a separate certificate or add the missing name with Certbot, then reload the web server. Test both the apex and www forms rather than assuming an alias was included.

The site returns 403, 404 or 502

  • 403: check execute permission on every parent directory and read permission on the files; review the site’s error log.
  • 404: verify the document root, index filename and application route. A correct hostname can still point to an empty or wrong directory.
  • 502: for a reverse proxy, confirm that the backend process is running, listening on the configured localhost port or socket and accepting the forwarded host and scheme.

Operational checklist

  1. Record the VPS IPv4 and, if used, IPv6 addresses.
  2. Create and verify A and AAAA records for both domains and their aliases.
  3. Install exactly one primary web server, or deliberately place one in front of the other.
  4. Create separate document roots, application users and logs.
  5. Add one Nginx server block or Apache VirtualHost per domain.
  6. Enable the files, run the appropriate syntax test and reload.
  7. Test each hostname over HTTP with normal DNS and with an explicit host-header test when diagnosing propagation.
  8. Issue certificates only after DNS and port 80 are ready; verify every certificate name.
  9. Run a renewal dry run, monitor logs and keep configuration and application backups.

With those layers separated, adding a third or fourth domain is the same pattern: publish its DNS records, create another isolated root and hostname definition, validate the configuration, then obtain its certificate. The VPS and IP address remain shared, while the hostnames, content, logs and application settings remain distinct.

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

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.