Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 601845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:45:32+00:00 2026-05-13T16:45:32+00:00

I am trying to host two websites using Apache from the same Ubuntu server.

  • 0

I am trying to host two websites using Apache from the same Ubuntu server. I have one ip address, and I only have one domain (which resolves to the ip address). So I want requests to the domain name to give one website, and requests to the ip address to give the other.

I have symlinks in /etc/apache2/sites-enabled to two files, pointing to the config for my two sites.

One contains:

<VirtualHost 1.2.3.4:80>
    ServerName 1.2.3.4
    stuff
</VirtualHost>

while the other contains

<VirtualHost domain.net:80>
    ServerName domain.net
    stuff
</VirtualHost>

However, when I start Apache, I get the following message:

[warn] VirtualHost 1.2.3.4:80 overlaps with VirtualHost domain.net:80, the first has precedence, perhaps you need a NameVirtualHost directive

and when I point my browser at either domain.net or 1.2.3.4 I get the site that I want associated with the ip address.

If I delete either symlink, then pointing a browser at either the domain name or the ip address gives the only enabled website. (As you would hope.)

As I understand it, both config files in sites-enabled are being loaded at once, and the one containing the ip address trumps the one containing the domain name. The warning suggests looking at the NameVirtualHost directive, but all the help I can find online refers to cases where you have two domain names pointing to the same ip address.

As always, and help or advice would be much appreciated.

(For what it’s worth, the websites are both Rails applications, and I’m deploying using Passenger, but I don’t think that’s important here.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T16:45:33+00:00Added an answer on May 13, 2026 at 4:45 pm

    This is how I do it:

    NameVirtualHost 1.2.3.4:80
    
    <VirtualHost 1.2.3.4:80>
        ServerName localhost
        DocumentRoot /var/www/default
    </VirtualHost>
    
    <VirtualHost 1.2.3.4:80>
        ServerName mydomain.net
        DocumentRoot /var/www/mydomain
    </VirtualHost>
    

    Apache looks for a suitable virtualhost for every request. If it doesn’t find one that matches the ServerName or any of the ServerAliases then it takes the first one. It doesn’t really matter what you use for the ServerName in the first VirtualHost as it will always be used if none of the other VirtualHosts match.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 347k
  • Answers 347k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer For this kind of thing in the past I've coded… May 14, 2026 at 6:23 am
  • Editorial Team
    Editorial Team added an answer Set Graphics.CompositingMode to CompositingMode.SourceCopy before drawing your image. May 14, 2026 at 6:23 am
  • Editorial Team
    Editorial Team added an answer Requesting user password in unprotected applications is a very bad… May 14, 2026 at 6:23 am

Related Questions

I have a single Rails 2.2.2 app that I want to 'share' with multiple
I've done a fair bit of mysql php programming but am pretty new to
can't I expose my methods as webmethods in a winform and have other clients
I am trying to write a PHP program to automatically created backups of MySQL
I am trying to create a rewrite rule that accomplishes two things: Redirect (www.)?domain.com

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.