Solved

adding virtual host to httpd.conf

Posted on 2010-11-08
12
864 Views
Last Modified: 2012-05-10
Hello,

I'm trying to set up an existing site on my WAMP server that uses virtual hosts.  Apache runs fine until I add the code for the virtual hosts to my httpd.conf file.  Once i add it, the server wont start and nothing is added to the error log so I can't figure out why it doesn't work.  Is it a syntax problem?  

This is what I add:
NameVirtualHost *:80

<VirtualHost *:80>
    DocumentRoot C:\wamp\www\sitesTrunk\vbwww\admin
    ServerName admin.vbwww.tld
</VirtualHost>
<VirtualHost *:80>
    DocumentRoot C:\wamp\www\sitesTrunk\vbwww\main
    ServerName vbwww.tld
    <Location /docs/>
        ForceType application/x-httpd-php
    </Location>
</VirtualHost>
<VirtualHost *:80>
    DocumentRoot C:\wamp\www\sitesTrunk\vbwww\members
    ServerName members.vbwww.tld
</VirtualHost>
<VirtualHost *:80>
    DocumentRoot C:\wamp\www\sitesTrunk\vbwww\files
    ServerName files.vbwww.tld
</VirtualHost>
<VirtualHost *:80>
    DocumentRoot C:\wamp\www\sitesTrunk\vbwww\main\version
    ServerName version.vbwww.tld
</VirtualHost>

Open in new window

0
Comment
Question by:b_rad_wright
  • 7
  • 4
12 Comments
 

Author Comment

by:b_rad_wright
ID: 34086174
PS - I just read that if i'd like localhost to continue to work i'd need to add that to my httpd.conf file and my host file as well so I've done that.  And the ServerNames listed above are already in my host file under the following pattern: 127.0.0.1    files.vbwww.tld

0
 
LVL 26

Expert Comment

by:arober11
ID: 34086270
As you've stated, not starting implies you've introduced a syntax error into your httpd.comf

So depending on the Apache version either uses the .exe to syntax checker e.g.

apache.exe -t


else make a copy of you httpd.conf, then remove all but one of the new Virtualhost blocks, start-it and if all ok, stop apache and repeat, adding back one virtualhost at a time till apache fails to start. If it didn't start with the initial block you've located the source of the error.


Oh what's your Listen directive look like e.g. Does it look anything like:

Listen 80
0
 

Author Comment

by:b_rad_wright
ID: 34086497
Ok.  I'm not sure what you are referring to on the apache.exe -t or where execute that command.  I'm assuming the command line...

as for the second suggestion, the only virtual host that worked was local host.

I am listening to 80 as well...just like you've listed.  
0
 
LVL 26

Expert Comment

by:arober11
ID: 34086537
Ref: "I'm not sure what you are referring to on the apache.exe -t", see: http://httpd.apache.org/docs/1.3/windows.html#signal
0
 

Author Comment

by:b_rad_wright
ID: 34086594
I'm new to apache so that doc is over my head.  What dir do i need to execute that command from?  I opened the console, changed dirs to where I have apache placed (C:\wamp\bin\apache\Apache2.2.11) and tried to execute that but cmd doesn't recognize that command.  

I know that is a bit of a rookie issue but I'm not following the doc you linked to...can you dumb it down a bit?
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

Author Comment

by:b_rad_wright
ID: 34086602
also, shouldn't my attempt at your "plan b" approach have showed us something we need to know?
0
 

Author Comment

by:b_rad_wright
ID: 34086643
not sure if this is of consequence but I attempted to run httpd -k start from the bin dir at c:\wamp\bin\apache\Apache2.2.11\bin and it said [error] (os 2) The system cannot find the file specified.  : No installed service named "Apache2.2".

0
 

Accepted Solution

by:
b_rad_wright earned 0 total points
ID: 34087523
ok.  so it's almost working
actually it is working
but i had to
a) remove the virtual hosts from the httpd.conf file
b) add them to the httpd-vhosts.conf file
c) make sure the include for the v-host file was uncommented
d) remove this line:
<Location /docs/>
        ForceType application/x-httpd-php
    </Location>
e) add a serveradmin, errorlogs, and customlogs fields to the httpd-vhosts.conf file
0
 
LVL 26

Expert Comment

by:arober11
ID: 34088489
So you've used my second solution:


" else make a copy of you httpd.conf, then remove all but one of the new Virtualhost blocks, start-it and if all ok, stop apache and repeat, adding back one virtualhost at a time till apache fails to start. If it didn't start with the initial block you've located the source of the error."

The virtual host definitions do not need to located in a separate file, so your steps b + c are unnecessary, as is your step e as any values outsife the new virtual hos definitions will be inherited, and the directives are optional anyway.


0
 

Author Comment

by:b_rad_wright
ID: 34088578
I tried your second solution and it did nothing.  When I did what you suggested, none of them worked so that didn't help because they were all "the source of the error."  Knowing they were all the error didn't move me any further to figuring out how to fix it.  I'm not totally sure why what I did worked but got me to the solution was this article - http://www.infinitedesigns.org/archives/217 - not your suggestions.  

Further, you didn't respond to my additional questions as I was working toward a solution so I haven't awarded partial points or assisted solutions since I took it from broke to fixed all on my own.

Sorry arober11, I'm not gonna award you points.  
0
 
LVL 26

Expert Comment

by:arober11
ID: 34089487
You can expect a day or so between posts, as this is a community supported forum, if you require someone to be instantly available to answer your questions you'll need employ an IT professional. The volunteer experts here have jobs / lives, which take precedence.

Anyway the error was obviously in your new entries, and you followed my suggestion of removing your the new entries, then adding them back, till you identified the erroneous <Location> block in your second V-host, so what are you arguing about.

Also as the easiest option of letting Apache test your configuration file for you, per the example I gave / paragraph I linked to, (have included below) was beyond your comprehension:  "I'm new to apache so that doc is over my head." you need to give the experts a chance to compose a reply that is at your level.
Another very useful feature is the configuration files test option. To test the Apache configuration files, run:



    apache -t



This is especially useful following alterations to the configuration files while Apache is still running. You can make the changes, confirm that the syntax is good by issuing the "apache -t" command, then restart Apache with "apache -k restart". Apache will re-read the configuration files, allowing any transactions in progress to complete without interruption. Any new request will then be served using the new configuration.

Open in new window

0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now