I'm attempting to host two websites using Apache in the same Ubuntu server. I've one ip, and that i have only one domain (which resolves towards the ip). And So I want demands towards the domain title to provide one website, and demands towards the ip to own other.
I've symlinks in /etc/apache2/sites-enabled to 2 files, pointing towards the config for my two sites.
One consists of:
<VirtualHost 126.96.36.199:80> ServerName 188.8.131.52 stuff </VirtualHost>
as the other consists of
<VirtualHost domain.net:80> ServerName domain.net stuff </VirtualHost>
However, after i start Apache, I recieve the next message:
[warn] VirtualHost 184.108.40.206:80 overlaps with VirtualHost domain.net:80, the first has precedence, perhaps you need a NameVirtualHost directive
so when I point my browser at either domain.internet or 220.127.116.11 I recieve the website which i want connected using the ip.
Basically remove either symlink, then pointing a browser at either the domain title or even the ip provides the only enabled website. (While you would hope.)
When I comprehend it, both config files in sites-enabled are now being loaded at the same time, and also the one that contains the ip trumps the main one that contains the domain title. The warning indicates searching in the NameVirtualHost directive, but all of the help I'm able to find online describes cases when you've two domains pointing towards the same ip.
Of course, and help or advice could be much appreciated.
(For which it's worth, those sites are generally Rails programs, and I am implementing using Passenger, however i don't believe that's important here.)
This is the way I actually do it:
NameVirtualHost 18.104.22.168:80 <VirtualHost 22.214.171.124:80> ServerName localhost DocumentRoot /var/www/default </VirtualHost> <VirtualHost 126.96.36.199:80> ServerName mydomain.net DocumentRoot /var/www/mydomain </VirtualHost>
Apache searches for a appropriate virtualhost for each request. Whether it does not locate one that suits the
ServerName or the
ServerAliases it takes the first. It does not really appear you utilize for that
ServerName within the first
VirtualHost as most commonly it is used if no other
Make certain you will find the instruction
Had this issue, here's what Used to do:
sudo vi /etc/apache2/httpd.conf
Add this line
NOTE: You are able to replace *:80 with your_ip_address:80
Now produce the domain title config file. I personally use the domain_title.com
sudo vi /etc/apache2/sites-available/domain.com
Add this towards the file
<VirtualHost *:80> ServerAdmin firstname.lastname@example.org ServerName www.domain.com ServerAlias domain.com DocumentRoot /var/www/domain.com/public_html/ ErrorLog /var/www/domain.com/logs/error.log CustomLog /var/www/domain.com/logs/access.log combined </VirtualHost>
Make certain the sites within the domain.com config is available
NOTE: make use of the mkdir command such as this as needed
sudo mkdir /var/www/domain.com/public_html/ sudo mkdir /var/www/domain.com/logs
Now we have to let the new config file such as this
sudo a2ensite domain.com
You need to visit a notice to restart apache, make use of this command
Now we want an evaluation file to see
sudo vi /var/www/domain.com/public_html/index.html
Then add text
Open your internet browser and see your new domain