Forum Moderators: phranque

Message Too Old, No Replies

virtual host entry?

         

steve_f

5:34 am on Dec 31, 2005 (gmt 0)

10+ Year Member



i have a domain (mydomain.tld) and it points to an ip address of my server. the problem is mydomain.tld/file.ext does NOT work while ipaddress/file.ext DOES work, but they should both work.

my registrar or whatever they're called has said i need to add avirtual host entry to httpd.conf to fix the problem. well ok, but i have no idea what this entry should look like.

ive read about it in the apache guide, name based entries, but it didn't make much sense to me.

paulsb

10:27 pm on Dec 31, 2005 (gmt 0)

10+ Year Member



Hi Steve!

First you have to configure your DNS server to point mydomain.tld to your web server.

Then you have to add to httpd.conf something like:

<VirtualHost *:80>
ServerName mydomain.tld
DocumentRoot /path/to/your/httpserver/files
</VirtualHost>

Try to restart apache and point your browser to [mydomain.tld...] and see if it works. Also you can check if DNS is configured correctly by checking name service (try dnstools.com and see if your domain name is configured and is accessable from outside).

Hope this helps,
- paul.

steve_f

8:35 am on Jan 2, 2006 (gmt 0)

10+ Year Member



well, that didn't work :(

my httpd.conf looks lie

<VirtualHost *>
ServerName mydomain.tld
DocumentRoot /path/to/your/httpserver/files
</VirtualHost>

I had to take out the port because apache said i couldn't mix ip's and ports. does it matter that i am running apache2 and that the port is missing?

steve_f

7:56 am on Jan 3, 2006 (gmt 0)

10+ Year Member



Anyone?

koen

8:52 am on Jan 3, 2006 (gmt 0)

10+ Year Member



Any chance you are using a windows version?

steve_f

10:10 am on Jan 3, 2006 (gmt 0)

10+ Year Member



Nope. I'm using Ubuntu (Linux).

koen

10:18 am on Jan 3, 2006 (gmt 0)

10+ Year Member



And does it help if you add NameVirtualHost? The end of my httpd file looks:

NameVirtualHost *:80

<VirtualHost *>
ServerName mydomain.tld
DocumentRoot /path/to/your/httpserver/files
</VirtualHost>

steve_f

8:04 pm on Jan 3, 2006 (gmt 0)

10+ Year Member



Having *:80 gives me an error that says the NameVirtualHost has no VirtualHost. Changing the *'s to have IP address says I can't mix IP's and Port's (odd). If I remove the port it starts without an error but still does not work.

encyclo

8:36 pm on Jan 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Are you using the default Apache 2.x setup in Ubuntu? Which version of Ubuntu are you using?

I am using Ubuntu 5.04 as my main desktop with Apache 2 and vhosts for each project. Virtual host support should be enabled already in the default configuration: to add a new one, go to:

/etc/apache2/sites-available/

You should see a

default
file. You add a new file for each vhost - my (very basic) setup is simply:

<VirtualHost *>
DocumentRoot "/home/example/public_html"
ServerName example.com
</VirtualHost>

Save as "example".

To activate the vhost, you need to symlink it from:

/etc/apache2/sites-enabled/

Like this:

ln -s /etc/apache2/sites-available/example /etc/apache2/sites-enabled/example

(all as root or with

sudo
, obviously)

Then just restart Apache for the changes to take effect:

/etc/init.d/apache2 restart

Just dig around

/etc/apache2/
and check out the documentation to get a feel of how it all works. One off-topic warning - by default Apache in Ubuntu is set up to send a charset header of UTF-8 for every page, which can cause big problems with sites not encoded in UTF-8.

steve_f

9:10 pm on Jan 3, 2006 (gmt 0)

10+ Year Member



Yep. Default setup, and 5.04.

I'm not getting any errors now, but it still does not work :(

ipaddress/file.ext works
mydomain.tld/file.ext returns

"Not Found

The requested URL /file.ext was not found on this server."

encyclo

9:12 pm on Jan 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try hard-coding the IP address on the server into the hosts file of your client machine. Then restart the browser and try again. If the page displays, then it may be a DNS problem. If not, check your error logs.

steve_f

5:54 am on Jan 4, 2006 (gmt 0)

10+ Year Member



Tried it. Didn't display. What error logs?

steve

9:10 am on Jan 4, 2006 (gmt 0)

10+ Year Member



From the command line try typing: Apache -s

This will show you how Apache parsed the config file. Check the IP addresses and server names for configuration errors.

steve_f

10:03 am on Jan 4, 2006 (gmt 0)

10+ Year Member



That command did nothing but I used -E to have it output errors to a log file.

(88)Address already in use: make_sock: could not bind to address [::]:80 no listening sockets available, shutting down

Despite "shutting down" the apache webserver is still up and running.

Also, I guess you are the reason I couldn't register "steve" :P

Romeo

12:24 pm on Jan 4, 2006 (gmt 0)

10+ Year Member



So the apache can't be started because an old incarnation is still up.
Kill 'em all.
Then start it new.

Regards,
R.

steve_f

1:45 am on Jan 6, 2006 (gmt 0)

10+ Year Member



Well then, now the log file has nothing in it at all.

steve_f

8:27 am on Jan 8, 2006 (gmt 0)

10+ Year Member



Bump!

steve_f

9:56 am on Jan 10, 2006 (gmt 0)

10+ Year Member



Hah! GOT IT WORKING! :D

Thank you for all your help. After all this they had to update a root zone file on their end, and now it works!

It only works with the www. prefix mind you. Is there something I can do so it works without it? Is it possible for me to make subdomains?

jdMorgan

1:35 am on Jan 26, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



www is a subdomain. Just add a ServerAlias [httpd.apache.org] for example.com in the <VirtualHost> section you already have for www.example.com

Jim