Forum Moderators: phranque

Message Too Old, No Replies

Problem with VirtualHost directive

cannot start Apache service after setting VirtualHost directive

         

kentscot

9:20 am on Dec 4, 2007 (gmt 0)

10+ Year Member



Hi all,
I am completely new to Apache as well as to this forum. What brought me here was my need to set up a home server running both Apache and IIS on WinXP SP2, where Apache works as a front end serving all the requests. If the request is for ASP.NET, Apache will redirect it to IIS. From my searching, it came to the usage of VirtualHost and mod_rewrite.
This is what I added to my httpd.conf:

NameVirtualHost *:80

<VirtualHost>
ServerName localhost
RewriteEngine On
ProxyVia Block
ProxyPreserveHost On
RewriteRule ^/DotNetApp(.*)$ [localhost:81...] [P,L]
</VirtualHost>

But Apache service could not start with these settings. What came out was just a message box saying "The requested operation has failed" and the start-up failed. I ran test configuration and the error message was "ServerName takes one argument, the Host name and port of the server."
I did try several solutions taken from this thread
[webmasterworld.com...]

but no use.

Please help!
Thank you

gergoe

12:49 pm on Dec 4, 2007 (gmt 0)

10+ Year Member



If it complains about the ServerName directive, then probably it is indeed wrong somewhere, if not in the VirtualHost container, then somewhere else, like in the main server configuration.

Besides of this, there's a little mistake you made, the RewriteRule should look like this:

RewriteRule ^/DotNetApp/(.*)$ [localhost:81...]  [P,L]

Not that it would make your Apache start up, but this makes the number of slashes in the resulting URL consistent.

Furthermore, I'd suggest you to use the ProxyPass [httpd.apache.org] directive instead of the rewriting, it is much simple to use. Don't forget to check the ProxyPassReverse [httpd.apache.org] directive too.

jdMorgan

1:07 pm on Dec 4, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The <VirtualHost> container needs several more directives in it to define the virtual host. Most notably, the DocumentRoot directive is missing in the code above, so the server won't even know the default filepath for this "domain."

More information above configuring virtual hosts is available on this page and at the pages linked from it:
[httpd.apache.org...]

Jim

kentscot

9:57 am on Dec 5, 2007 (gmt 0)

10+ Year Member



Thank you for your replies.
I changed ServerName to ServerAlias, and it works! I absolutely have no idea about why. Perhaps I have to study more on Apache.