Help - Search - Members - Calendar
Full Version: Subdomains In Apache
Zymic Webmaster Forums > Web Design & Development > General Web Design Discussion
death2y
I hope this is the right forum, there is not general web programming, so this seemed fit.

Anyway, I'm trying to make an image gallery, and I'd like it to be separate from my main website for convenience, so on my machine I'm trying to set up apache so I have localhost (my main website) and images.localhost (my image gallery), so in my httpd.conf I added the lines:
CODE
NameVirtualHost images.*:80
<VirtualHost images.*:80>
ServerName images.localhost
DocumentRoot /exthd/jeff/images_gallery
</VirtualHost>

then I added images.localhost to my hosts file.
This is exactly what I should do, according to what I was able to find, though all it does is make images.localhost go to localhost.
Bread
A few lines will be causing you issues (more than likely issues reported in the error_log).

CODE
NameVirtualHost images.*:80


I'll start with NameVirtualHost, this directive is for specifying which adaptor / IP address to bind the virtual host to, unless you have either multiple network cards, or virtual interfaces you want to serve the site via, you won't need to change this from:

CODE
NameVirtualHosting *:80


All that line says is, listen to all interfaces on port 80.

Another issue is that you're doing:

CODE
<VirtualHost images.*:80>


'images.*' is not a FQD, so it won't work.

Wildcarding is only used for listening on all IP addresses, you can here again, just leave it as:

CODE
<VirtualHost *:80>


Or perhaps if you like, you can do:

CODE
<VirtualHost images.localhost:80>


You can skip the port if you specify the listening port, you'll find that most times this is already specified in the server configuration file, so you can omit 'Listen 80' if you know it already exists.

CODE
Listen 80
NameVirtualHost *

<VirtualHost *>
   ServerName images.localhost
   DocumentRoot /exthd/jeff/images_gallery
</VirtualHost>

<VirtualHost *>
   ServerName another.localhost
   DocumentRoot /exthd/jeff/somewhereelse
</VirtualHost>


Manual page on VirtualHosts:
http://httpd.apache.org/docs/2.0/mod/core.html#virtualhost

Hope that helps.
death2y
Okay, kinda get it.
Get it enough, at least, that I'll be able to do it again if I need to

Thanks
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.