Sponsored by NuSphere - PHP Software for PHP Application Developers - On Sale This Week for $100



Go Back   PHP-Editors > Linux, Apache, MySQL > Apache Help

Apache Help Post any question relating to Apache here and hopefully someone can help

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 2004-08-22, 04:56 PM
Jordon Bedwell
Guest
 
Posts: n/a
Default

Hello,

I am having some problems with apache 2 and getting subdomains working. I thought I had everything right.

OS: Windows Xp

Server: Apache/2.0.50 (Win32) PHP/5.0.0 DAV/2 Server

Here is what i have in httpd.conf

### Section 3: Virtual Hosts
#
# VirtualHost: If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs-2.0/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
#NameVirtualHost 127.0.0.1:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
#
# First VirtualHost acts as a "catchall" for when nothing else matches
#
#
#
# main site (localhost)
# also catches anything that doesn't have a Host: header we recognise
<VirtualHost *:80>
ServerName localhost:80
DocumentRoot "C:/www"
ServerAdmin jordon.bedwell@coldfusionzone.com
ErrorLog logs/localhost_error.log
CustomLog logs/localhost_access.log combined
</VirtualHost>

# sqladmin (sqladmin.localhost)
<VirtualHost *:80>
ServerName sqladmin.localhost:80
DocumentRoot "C:/www/config/phpmyadmin"
ServerAdmin admin@php-helper.com
ErrorLog logs/sqladmin.localhost_error.log
CustomLog logs/sqladmin.localhost_access.log combined
</VirtualHost>
<Directory C:/www/>
Options All
AllowOverride All
Order Allow,Deny
Allow from All
</Directory>

# jordonbedwell host (sqladmin.localhost)
<VirtualHost jordonbedwell:80>
ServerName jordonbedwell.localhost:80
DocumentRoot "C:/www/sites/jordonbedwell/html_public"
ServerAdmin admin@php-helper.com
ErrorLog logs/jordonbedwell.localhost_error.log
CustomLog logs/jordonbedwell.localhost_access.log combined
</VirtualHost>
<Directory /www/sites/jordonbedwell/html_public>
Options All
AllowOverride All
Order Allow,Deny
Allow from All
</Directory>



Here is what I have in the hosts file for windows:

127.0.0.1 localhost www.localhost jordonbedwell.localhost www.jordonbedwell.localhost sqladmin.localhost www.sqladmin.localhost
127.0.0.1 sqladmin.localhost www.sqladmin.localhost
127.0.0.1 jordonbedwell.localhost www.jordonbedwell.localhost

# p.s. You can specify wild-cards within an hosts file so
# if need some subdomains you need to add them by hand code



Thank you ahead of time!

Jordon Bedwell
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 2004-08-22, 05:21 PM
Xnuiem's Avatar
Senior Member
 
Join Date: May 2004
Location: DFW, Texas
Posts: 1,104
Xnuiem will become famous soon enough
Send a message via Yahoo to Xnuiem
Default

Since localhost isnt an actual domain, I do not think subdomains work with it. I just tried to access some subs I have from one of my servers, granted it is Solaris running Apache 1, but it didnt work either, even though the subdomains do work when using a FQDN.
__________________
I rarely give code examples.
No, I have never used IIS or Windows of any kind as a web server. Get a real OS!
Please don't PM me, I won't respond.
Reply With Quote
  #3 (permalink)  
Old 2004-08-22, 05:33 PM
Junior Member
 
Join Date: Aug 2004
Posts: 1
jordonbedwell
Send a message via AIM to jordonbedwell Send a message via MSN to jordonbedwell
Default

ha ha I have spend 2 days wondering if that much has changed from apache 1 to 2 and if i have really forgotten that much. However many people have suggested that it is possible. But maybe it isnt because it isnt a fully qualified domain. I think Ill move it to a non-internet enabled machine and spoof a domain and trick the devnet! if there are any other suggestions please do let me know!
Reply With Quote
  #4 (permalink)  
Old 2007-03-06, 06:08 AM
Junior Member
 
Join Date: Mar 2007
Posts: 1
romans5n1 is on a distinguished road
Default It actually is very possible, and here's how:

The apache conf looks good, the only thing that is lacking is to make the necessary changes to your OS's hosts file so that it routes it back to your machine instead of trying to find whatever.localhost on the net.

Depending on your operating system, this file will be located at:

Linux : /etc/hosts (use sudo or login as root)
Windows XP : C:\windows\system32\drivers\etc\hosts
Windows 2K : C:\winnt\system32\drivers\etc\hosts
Windows 98/ME : C:\windows

For each subdomain on localhost, add:

127.0.0.1 subdomain.localhost computer-name (Linux)

-or-

127.0.0.1 subdomain.localhost (Windows)

And that's all there is too it. Ubuntu Edgy Eft (Linux) didn't require a restart, but other distros might, and Windows most likely will. Hope that helps.

Last edited by romans5n1; 2007-03-06 at 06:12 AM.
Reply With Quote
Must read Review for Serious PHP Developers


NuSphere PhpED 5.5 : The Staff of php-editors.com recently spent a few days working with NuSphere PhpED 5.5 (a popular PHP IDE) and NuCoder 2.0 (a PHP Encoding Utility), read up on all the details.

Sponsored Links
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 06:13 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.