Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple domains in Apache on Ubuntu

Status
Not open for further replies.

oxygene

Technical User
Mar 23, 2002
66
CA
I have tried to read many FAQ's and websites but cannot get a second domain to work in Apache.

The first domain works fine at rtrip.net. The second one eltms.net does not work and keeps pulling up rtrip.net.

Here are my files for anyone who can help me.

In /etc/apache2/httpd.conf: I added NameVirtualHost *:80 at the end of the file.

In :/etc/apache2/sites-available: I created a new file called eltms.net and this is what I put in the file:

NameVirtualHost *:80

<VirtualHost *:80>
ServerAdmin webldamin@rtrip.net
DocumentRoot "/var/www"
ServerName ServerAlias rtrip.net
ErrorLog "/var/log/apache2/error.log"
CustomLog "/var/log/apache2/access.log" common
</VirtualHost>

<VirtualHost *:80>
ServerAdmin webldamin@rtrip.net
DocumentRoot "/var/ ServerName ServerAlias eltms.net
ErrorLog "/var/ CustomLog "/var/ common
</VirtualHost>
-------------------------
I enabled the site with a2ensite eltms.net and reloaded apache.

/etc/hosts:

127.0.0.1 localhost
127.0.0.1 rtrip.net
127.0.0.1 eltms.net
192.168.1.3 rtrip.net rtrip.net
127.0.1.1 rtrip.net
192.168.1.1 gateway
192.168.1.2 caslim.rtrip.lan caslim
192.168.1.4 crain.rtrip.lan crain
192.168.1.7 cbot.rtrip.lan
192.168.1.8 cnbot.rtrip.lan
192.168.1.14 ctrench.rtrip.lan ctrench

Can anyone help me to get eltms.net to serve it's own page that is different from rtrip.net? Thanks.




Life is what you make it.
 
Rtrip.net is now ok after reboot.

eltms.net -> Help.

If I liked MS I would be up and running with IIS. Wonder why linux/unix is so hard.

Life is what you make it.
 
In your /etc/apache2/apache2.conf, you have
Code:
NameVirtualHost *:80

ServerName rtrip.net
There are no such references in my /etc/apache2/apache2.conf

There are some other minor numeric value differences which are different which are unlikely to have any effect at this stage.

/etc/apache2/httpd.conf is empty and /etc/apache2/ports.conf matches yours.

Assuming the code in /etc/apache2/sites-enabled/eltms.net and /etc/apache2/sites-enabled/rtrip.net is correct, suggest you try removing the extra code in /etc/apache2/apache2.conf, run a2ensite, etc and see what happens.

FAQ184-2483​
Chris [pc2]
PDFcommander.com
motrac.co.uk
 
Oxygene, I want to ask a potentially stupid question here.

You said that all was well after a reboot. That being the case, did you do either a restart of apache2 /and/or/ a force-reload?

I ask (and this came up in another thread) because you must restart apache to get any changes to take effect. A reboot certainly counts as a restart.

Also, just to comment on an earlier statement. I am running multiple virtual hosts and I did put them in the same file. I don't think this is necessary, or even necessarilly recommended. It is just what I did.


 

I have an advantage over the rest of you in this forum -I am an apache/linux newbie. [smile]

With therefore limited knowledge and an unwillingnes to stray from the chosen path, I faithfully follow the procedures outlined in this previously mentioned article, and it works in a parallel situation to that outlined by oxygene!

If it still does not work after trying the suggestions made, try reinstalling Ubuntu 9.04 Server edition and work through the previously mentioned article, using the defaut Ubuntu vales.

FAQ184-2483​
Chris [pc2]
PDFcommander.com
motrac.co.uk
 
I'd hold off on reinstalling ubuntu. I've been on this forum many moons and most people who have problems with apache are running ubuntu or windoze. In fact, most people who have problems in the linux server and linux desktop forums are also running ubuntu. I'm not saying that it is a bad distro but based on these facts, one would have to assume that they are very poorly documented and support seems to leave something to be desired also.
 
Will try these suggestions and get back to the posting. I want to try to fix the issue without reinstalling Ubuntu so I can learn what to do if this should happen again.

I did a reload and restart of apache as asked above which usually brings up rtrip.net but that one time it would not and I had to reboot the machine fully.

Will post again tomorrow the results of further changes based on what's posted above. Thanks so far ya'll.

Life is what you make it.
 
You shouldn't have to mess with this so much. Here is what you need to do:

1. Get rid of the ServerName Directive in apache2.conf.

2. Edit The line that says "Include /etc/apache2/sites-enabled/" to read "Include /etc/apache2/sites-enabled/vhosts.conf".

3. Create this vhost.conf file and put all your vhosts in it.

4. Restart apache

5. Jump for joy and give RhythmAce a star. ;-)

You can make changes later but I just wanted to show you that it will work.

 
Response to ChrisRChamberlain:-

I removed NameVirtualHost *:80

ServerName rtrip.net

and got the following error:
* Reloading web server config apache2 [Tue Jul 07 22:27:02 2009] [error] VirtualHost *:80 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results
[Tue Jul 07 22:27:02 2009] [error] VirtualHost *:80 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results
[Tue Jul 07 22:27:02 2009] [error] VirtualHost _default_:443 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results
[Tue Jul 07 22:27:02 2009] [warn] NameVirtualHost *:80 has no VirtualHosts


-----------------

Will try other ideas above.

Life is what you make it.
 
RhythmAce - I followed your instructions and still cant route to both rtrip.net and eltms.net.

Does this vhosts.conf file below look correct or should I change anything? I also made the changes you mentioned to apache2.conf.


# rtrip.net (/etc/apache2/sites-available/#
<VirtualHost *:80>
ServerAdmin webldamin@rtrip.net
ServerName rtrip.net
ServerAlias *.rtrip.net

# Indexes + Directory Root.
DirectoryIndex index.html
DocumentRoot /var/www

# CGI Directory
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Location "/usr/lib/cgi-bin">
Options +ExecCGI
</Location>


# Logfiles
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
</VirtualHost>

# Eltms.net (/etc/apache2/sites-available/#
<VirtualHost *:80>
ServerAdmin webldamin@rtrip.net
ServerName ServerAlias eltms.net

# Indexes + Directory Root.
DirectoryIndex index.html
DocumentRoot /var/
# CGI Directory
ScriptAlias /cgi-bin/ /var/ <Location /cgi-bin>
Options +ExecCGI
</Location>


# Logfiles
ErrorLog /var/others/eltms.net/logs/error.log
CustomLog /var/others/eltms.net/logs/access.log combined
</VirtualHost>


Life is what you make it.
 
After putting both sites in one vhosts.conf file I am still getting the following error:

* Restarting web server apache2 [Tue Jul 07 23:11:26 2009] [error] VirtualHost *:80 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results
[Tue Jul 07 23:11:26 2009] [error] VirtualHost *:80 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results
[Tue Jul 07 23:11:26 2009] [warn] NameVirtualHost *:80 has no VirtualHosts
[Tue Jul 07 23:11:26 2009] [error] VirtualHost *:80 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results
[Tue Jul 07 23:11:26 2009] [error] VirtualHost *:80 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results
[Tue Jul 07 23:11:26 2009] [warn] NameVirtualHost *:80 has no VirtualHosts



Life is what you make it.
 
Ok changing a few items which I had changed already and now using two files in sites-available: default and eltms.net.

Default is for rtrip.net website and this now works fine.

Eltms.net seems to be connecting as I get no error in the browser but does not pull up the index page from eltms.net, it instead redirects immeditely to rtrip.net/index.html. Weird.

Life is what you make it.
 
oxygene said:
...using two files in sites-available: default and eltms.net
That not the way suggested in the previously mentioned article/tutorial, but it remains your choice as to whether to follow his advice.


If you follow his way of doing it, you leave the default file in the condition found after a new install and add rtrip.net, currently missing, and eltms.net to /etc/apache2/sites-available.

I have the same error messages but everything works as expected.

FAQ184-2483​
Chris [pc2]
PDFcommander.com
motrac.co.uk
 
OK - Time to put an end to this foolishness. Let's take a peek at what apache is seeing as far as vhosts. Type "httpd -S". This will show the virtual hosts. More importantly, it shows where it found that vhost defined (file and line number). Secondly, you should have NO default servers. The only time you have a default is when you have only one vhost. The exception is when you also have one ssl site. Normally, you would use ip based addressing for ssl but since only one site would be using port 443, a default works fine for that. Did you get rid of the ServerName directive in apache2.conf?
 
To ChrisRChamberlain:
I tried the steps outlined in the article mentioned above but it still did not work and I could not route to rtrip.net as well.

I will back track and try it again just to make sure I didn't miss a step and post later.

Life is what you make it.
 
I tried to enter httpd -S but it said command not found.

I got rid of the ServerName directive as well in apache2.conf.

I didn't mention but I have a default-ssl file as well using port 443.

I found a website with someone having the same issue as mine:

Apache Virtual Hosts forwarding to wrong directories


I will remove try from this site and will also remove the default file as well but should I also remove the default-ssl?

Life is what you make it.
 
Use apache2ctl -S instead. As a sanity check I just ran the same thing on my server and got the same result.

The executable program name is one of the configurable options. If you are using Ubuntu (debian) and downloaded the binary from the repository, the default is for it to be called apache2 and the executable directory is /usr/sbin.
 
ChrisRChamberlain, RhythmAce & Noway2, BIG THANX TO ALL OF YOU. IT NOW APPEARS TO BE WORKING - at least locally at home. I will test it from a different internet connection at work tomorrow but right now I can route to both site: rtrip.net and eltms.net.

Now I can remake the websites and move them to my work. I work for myself so I am trying to save a few bucks per month on web-hosting fees by hosting a few sites at work myself.

I removed NameVirtualHost *:80 & ServerName rtrip.net from apache2.conf and remade the sites-available files with basic settings in the files so I took out a lot of the extra content that I probable don't need right now.



apache2ctl -S worked by the way.

I learned a few extra things from you all as well.

Life is what you make it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top