logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Correct subdomain code in httpd.conf
Author
rabidjade



Joined: 12 Oct 2006
Posts: 25

PostPosted: Tue 07 Nov '06 16:18    Post subject: Correct subdomain code in httpd.conf Reply with quote

I want to add a subdomain to my server with a domain I already own. I looked and can't find the answer I need. This is the current code I have for my website:

Code:

<VirtualHost *:80>
ServerName www.website.com
ServerAlias website.com
DocumentRoot "C:\Program Files\Apache Group\Apache2\www\website.com"
ErrorLog "C:\Program Files\Apache Group\Apache2\logs\website\error.log"
CustomLog "C:\Program Files\Apache Group\Apache2\logs\website\access.log" common
</VirtualHost>


How would I edit this for a subdomain? I found about 5 different answers on various websites and figured I could try here.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Tue 07 Nov '06 17:02    Post subject: Reply with quote

You only missed

NameVirtualHost *:80

if you are adding virtual hosts to an existing web server, you must also create a <VirtualHost> block for the existing host. The ServerName and DocumentRoot included in this virtual host should be the same as the global ServerName and DocumentRoot. List this virtual host first in the configuration file so that it will act as the default host.

For more info and infos from the first hand see the original documentation
http://httpd.apache.org/docs/2.2/en/vhosts/name-based.html
Back to top
rabidjade



Joined: 12 Oct 2006
Posts: 25

PostPosted: Wed 08 Nov '06 0:55    Post subject: Reply with quote

James Blond wrote:
You only missed

NameVirtualHost *:80

if you are adding virtual hosts to an existing web server, you must also create a <VirtualHost> block for the existing host. The ServerName and DocumentRoot included in this virtual host should be the same as the global ServerName and DocumentRoot. List this virtual host first in the configuration file so that it will act as the default host.

For more info and infos from the first hand see the original documentation
http://httpd.apache.org/docs/2.2/en/vhosts/name-based.html


I have 3 virtual hosts and the code you mention is there. I only posted this in
here so I could find out what to change as an example in one block. I'll try that link again and see if there's something I overlooked.

edit: this is what I have so far (does not work), this is only one block out of 3 VH's I have.

<VirtualHost *:80>
ServerName forums.website.com
ServerAlias forums.website.com
DocumentRoot "C:\Program Files\Apache Group\Apache2\www\forums.website.com"
ErrorLog "C:\Program Files\Apache Group\Apache2\logs\forums.website.com\error.log"
CustomLog "C:\Program Files\Apache Group\Apache2\logs\forums.website.com\access.log" common
</VirtualHost>
Back to top
Brian



Joined: 21 Oct 2005
Posts: 209
Location: Puyallup, WA USA

PostPosted: Wed 08 Nov '06 2:28    Post subject: Reply with quote

Code:
NameVirtualHost *:80

<VirtualHost *:80>
   ServerName forums.website.com
   ServerAlias *.website.com
   DocumentRoot "C:\Program Files\Apache Group\Apache2\www\forums.website.com"
   ErrorLog "C:\Program Files\Apache Group\Apache2\logs\forums.website.com\error.log"
   CustomLog "C:\Program Files\Apache Group\Apache2\logs\forums.website.com\access.log" common
</VirtualHost>
Back to top
rabidjade



Joined: 12 Oct 2006
Posts: 25

PostPosted: Wed 08 Nov '06 4:53    Post subject: Reply with quote

Still doesn't work. Other than adding the new code to httpd.conf and adding in the directories/content, what else needs to be done?
Back to top
Brian



Joined: 21 Oct 2005
Posts: 209
Location: Puyallup, WA USA

PostPosted: Wed 08 Nov '06 6:10    Post subject: Reply with quote

What happens when you try to view the vhost?

Have you checked the error.log, access.log, php.log, or other logs as is appropriate for your configuration?

Try this:

Code:
NameVirtualHost *:80

<VirtualHost *:80>
   ServerName forums.website.com
   DocumentRoot "C:/Program Files/Apache Group/Apache2/www/"
</VirtualHost>
NOTE: In Apache and PHP you don't need to use the '\' backslash, you can use the *nix style '/' forward slash.

I see that you had:

DocumentRoot "C:/Program Files/Apache Group/Apache2/www/forums.website.com"

Are you sure you need the:

forums.website.com

...part? You don't have a directory with this name do you? I ask because you certainly can create directories with periods in their name, but that seems odd to do.

Start with the bare minimum. If this doesn't work, based on the info you supplied, you have errors elsehwere. How could anyone over the internet figure out where without more info?

Always check the log files, even the EVENT viewer in your OS's admin section.

Always start with the basics and DO NOT copy and paste generic code without understanding it.
Back to top
rabidjade



Joined: 12 Oct 2006
Posts: 25

PostPosted: Wed 08 Nov '06 15:50    Post subject: Reply with quote

Here is what I have right now. I changed the directories to make things more easier to manage. This is exactly how it appears in the httpd.conf file:

Code:
NameVirtualHost *:80

<VirtualHost *:80>
ServerName www.policeposers.com
ServerAlias policeposer.com
DocumentRoot "C:\Program Files\Apache Group\Apache2\www\policeposers.com"
ErrorLog "C:\Program Files\Apache Group\Apache2\logs\policeposers\error.log"
CustomLog "C:\Program Files\Apache Group\Apache2\logs\policeposers\access.log" common
</VirtualHost>

NameVirtualHost *:80


<VirtualHost *:80>
ServerName forums.policeposers.com
ServerAlias *.policeposers.com
DocumentRoot "C:\Program Files\Apache Group\Apache2\www\policeposersforums"
ErrorLog "C:\Program Files\Apache Group\Apache2\logs\policeposersforums\error.log"
CustomLog "C:\Program Files\Apache Group\Apache2\logs\policeposersforums\access.log" common
</VirtualHost>

NameVirtualHost *:80

<VirtualHost *:80>
ServerName www.wagnersafety.com
ServerAlias wagnersafety.com
DocumentRoot "C:\Program Files\Apache Group\Apache2\www\wagnersafety.com"
ErrorLog "C:\Program Files\Apache Group\Apache2\logs\wagnersafety\error.log"
CustomLog "C:\Program Files\Apache Group\Apache2\logs\wagnersafety\access.log" common
</VirtualHost>


IThe other two VH's work fine when checked. Accessing this sub domain shows me a "server not found" page. I restarted Apache and found the following error log messages:

Code:
[Wed Nov 08 07:31:12 2006] [notice] Apache/2.0.55 (Win32) PHP/4.4.3 configured -- resuming normal operations
[Wed Nov 08 07:31:12 2006] [notice] Server built: Oct  9 2005 19:16:56
[Wed Nov 08 07:31:12 2006] [notice] Parent: Created child process 316
[Wed Nov 08 07:31:12 2006] [warn] NameVirtualHost *:80 has no VirtualHosts
[Wed Nov 08 07:31:12 2006] [warn] NameVirtualHost *:80 has no VirtualHosts
[Wed Nov 08 07:31:12 2006] [warn] NameVirtualHost *:80 has no VirtualHosts
[Wed Nov 08 07:31:12 2006] [warn] NameVirtualHost *:80 has no VirtualHosts
[Wed Nov 08 07:31:13 2006] [notice] Child 316: Child process is running
[Wed Nov 08 07:31:13 2006] [notice] Child 316: Acquired the start mutex.
[Wed Nov 08 07:31:13 2006] [notice] Child 316: Starting 250 worker threads.


I have a feeling that my Apache install isn't recognizing the sub domain as anything, I have the VH's setup wrong or something in the httpd.conf file isn't turned on like it should be. Probably a noob mistake since I'm still new with Apache so any help is appreciated.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Wed 08 Nov '06 17:21    Post subject: Reply with quote

Put NameVirtualHost *:80 only ONE time into httpd.conf (before your vhosts) and not several times Wink
Back to top
rabidjade



Joined: 12 Oct 2006
Posts: 25

PostPosted: Wed 08 Nov '06 23:38    Post subject: Reply with quote

edit: I think it was a problem with my domain name company. Thanks for the help people!

James Blond wrote:
Put NameVirtualHost *:80 only ONE time into httpd.conf (before your vhosts) and not several times Wink


Did this with no change. Although it did trim down the error log a bit.

Code:
[Wed Nov 08 15:37:41 2006] [notice] Apache/2.0.55 (Win32) PHP/4.4.3 configured -- resuming normal operations
[Wed Nov 08 15:37:41 2006] [notice] Server built: Oct  9 2005 19:16:56
[Wed Nov 08 15:37:41 2006] [notice] Parent: Created child process 2160
[Wed Nov 08 15:37:42 2006] [notice] Child 2160: Child process is running
[Wed Nov 08 15:37:42 2006] [notice] Child 3032: Released the start mutex
[Wed Nov 08 15:37:42 2006] [notice] Child 2160: Acquired the start mutex.
[Wed Nov 08 15:37:42 2006] [notice] Child 2160: Starting 250 worker threads.
[Wed Nov 08 15:37:43 2006] [notice] Child 3032: Waiting for 250 worker threads to exit.
[Wed Nov 08 15:37:43 2006] [notice] Child 3032: All worker threads have exited.
[Wed Nov 08 15:37:43 2006] [notice] Child 3032: Child process is exiting


What else could I look at?
Back to top
Brian



Joined: 21 Oct 2005
Posts: 209
Location: Puyallup, WA USA

PostPosted: Thu 09 Nov '06 1:02    Post subject: Reply with quote

Did you enter the DNS records at your domain's registrar?

I use GoDaddy for my domains and I host my DNS at ZoneEdit. For me, I purchase the domain, then I add the domain and IP to the list at my commercial account at ZE, you can get a free account with ZE as well. Then I take the DNS server names and enter them at GoDaddy.

Did you take similar steps with your place of registration and DNS hosting?

Do you have a Static IP?
Back to top
rabidjade



Joined: 12 Oct 2006
Posts: 25

PostPosted: Thu 09 Nov '06 2:36    Post subject: Reply with quote

I have a static IP and my domain name is through http://www.cheap-domainregistration.com/ Seems like a cheap fly by night company but I've had good results with them.

When I first signed up I was told that any subdomain were automaticly forwarded to the IP address to be resolved by the server. I checked today and found this wasn't true and you needed to enter each record in manually.

Would I add a subdomain in as an Address record (main record) or as an Alias Record? As you probably can tell this is my first experience with subdomains.
Back to top
rabidjade



Joined: 12 Oct 2006
Posts: 25

PostPosted: Thu 09 Nov '06 5:16    Post subject: Reply with quote

All is well now. I entered the information in the wrong spot with my domain name service. Thanks for the help folks.
Back to top


Reply to topic   Topic: Correct subdomain code in httpd.conf View previous topic :: View next topic
Post new topic   Forum Index -> Apache