Sheffield Forum
Your message here

Need help with apache VirtualHost config
Home > General Forums > Computer & Tech Chat

Reply
 
Thread Tools Search this Thread
Old 21-06-2012, 19:40   #1
DaFoot
Frozen Banana
 
DaFoot's Avatar
 
Moderator
Join Date: Aug 2004
Location: location location!
Total Posts: 10,688
Send a message via MSN to DaFoot
I have a lump of code I've been given to edit. Due to the interesting way it's been created it has to live at the root of my domain... ie localhost/.

However, I want to be able to use localhost/oldapp to get at sites I had previously been working on.


# default for any not matched elsewhere - this goes to root of newapp on disk
<VirtualHost *:80>
ServerName localhost
DocumentRoot /var/www/html/newapp
</VirtualHost>
# now try to pick out specific URLs
<VirtualHost *:80/anothersite>
DocumentRoot /var/www/html/anothersite
ServerName localhost
</VirtualHost>

It's been a good 10 years 6 or 7 years since I've done this stuff and it seems I've forgotten how it should be done!
Use it or lose it I guess!
__________________
"The wise man speaks because he has something to say, the fool because he has to say something."
Web developer | Pet photography | Marathon efforts
  Reply With Quote
Sponsored Links - Register and/or Login to hide this ad.
Old 21-06-2012, 19:57   #2
kinetic
Registered User
 
Join Date: Jun 2012
Total Posts: 513
config files get prioritised top to bottom. So *.80 would override *:80/anothersite

Try putting anothersite first
  Reply With Quote
Old 21-06-2012, 20:00   #3
DaFoot
Frozen Banana
 
DaFoot's Avatar
 
Moderator
Join Date: Aug 2004
Location: location location!
Total Posts: 10,688
Send a message via MSN to DaFoot
Reordered then, *:80 still gets them all.
__________________
"The wise man speaks because he has something to say, the fool because he has to say something."
Web developer | Pet photography | Marathon efforts
  Reply With Quote
Old 21-06-2012, 20:09   #4
kinetic
Registered User
 
Join Date: Jun 2012
Total Posts: 513
Cant you just add "127.0.0.1 anothersite" into your hosts file then do:

<VirtualHost *:80>
ServerName anothersite
DocumentRoot /var/www/html/anothersite
</VirtualHost>

Or is there a reason you can't do that?
  Reply With Quote
Old 21-06-2012, 20:17   #5
steev
Registered User
 
steev's Avatar
 
Join Date: Sep 2004
Total Posts: 2,083
If I were doing that I'd just run the awkward code on another port.

Look for the Listen line in httpd.conf (RH/CentOS) or ports.conf (I think on debian/ubuntu) & add another line for port 81, then...

<VirtualHost *:81>

& just ht tp :/ / 127.0.0.1:81

**edit - just seen kinetic's answer. Yeh, or that.
__________________
Are you going to come along quietly, or am I going to have to use ear plugs?
  Reply With Quote
Old 21-06-2012, 20:32   #6
DaFoot
Frozen Banana
 
DaFoot's Avatar
 
Moderator
Join Date: Aug 2004
Location: location location!
Total Posts: 10,688
Send a message via MSN to DaFoot
Ahh yes, another port. That appears to work. Move the awkward app off to another port, so presumably I can now remove my *:80 virtual host and let apache work as it was doing (sylinks to elsewhere in system) on port 80.
__________________
"The wise man speaks because he has something to say, the fool because he has to say something."
Web developer | Pet photography | Marathon efforts
  Reply With Quote
Old 22-06-2012, 10:31   #7
DaFoot
Frozen Banana
 
DaFoot's Avatar
 
Moderator
Join Date: Aug 2004
Location: location location!
Total Posts: 10,688
Send a message via MSN to DaFoot
Port separation I liked, but problematic when it comes to some testing I was trying to do and cross port JS.

Ended up with hosts changes and httpd.conf:
Code:
NameVirtualHost localhost
<VirtualHost localhost:80>
   DocumentRoot /var/www/html
   ServerName localhost
</VirtualHost>
<VirtualHost anothersite:80>
   ServerName anothersite
   DocumentRoot /var/www/html/anothersite
</VirtualHost>
Thanks for input guys
__________________
"The wise man speaks because he has something to say, the fool because he has to say something."
Web developer | Pet photography | Marathon efforts
  Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search



All times are GMT. The time now is 21:38.
POSTS ON THIS FORUM ARE NOT ACTIVELY MONITORED
Click "Report Post" under any post which may breach our terms of use.
©2002-2012 SheffieldForum.co.uk | Powered by vBulletin ©2013