Jump to content

Recommended Posts

Posted
Ok I have Apache running fine and I am setting up various things on the server. The problem is I have set up virtual hosts and now seem to have to set up one for everything I install otherwise it just directs me to the first virtual host. Have I set something up wrong or is this just the way it is?
Posted

It is amazing how many times you can look through something and miss what you need. I've looked at that doc at least twice and not seen what I needed until now.

 

For future reference add:

 

DocumentRoot /www/default
 

 

to the virtual hosts file and all is well :D Huzzah.

Posted

My typical set up is as follows:

 

vhosts.conf (because I like them all together and don't trust a2en/dis site)

 

Default vhost at the top for ServerName mywebhost.com and ServerAlias http://www.mywebhost.com so stuff like http://www.mywebhost.com/forums /bugs /admin etc all 'just' work for anything I install.

 

I then have separate name based vhosts if its on a single IP for bob.mywebhost.com and jane.mywebhost.com to an individual folder so they too can have bob.mywebhost.com/forums /bananas etc.

 

If you want to see some configs / examples of what I have give me a shout.

  • Thanks 1
Posted

Thanks kmount, I think that is what I need first, a default entry.

 

ZH: I have my webserver on serverx. I have installed moodle and assigned it to a virtual host of moodle.server.com. After that any web app I have installed, such as joomla, I have had to add a virtual host and dns host to be able to get at it. I could no longer just go http://serverx/joomla. If I tried it would think /joomla was a folder under moodle.

 

I'll try entering a default entry and see what I can see.

Posted

Yep that did it. It was what I thought the solution above should have done. I now have:


   DocumentRoot "{htdocs path}"
   ServerName {ipaddress}

 

As my first virtual host so now anything that server hasn't been explicitly told about it will go to the normal IP address. & i tested it before rejoicing so it really seems to work!

Posted

I tend to do mine similarly but rather than IP I use names.

 

NameVirtualHost 1.2.3.4:80

 

ServerAdmin [email protected]

DocumentRoot /home/mysite/www

ServerName mysite.com

ServerAlias http://www.mysite.com

ErrorLog /home/mysite/logs/errorlog.txt-www

CustomLog /home/mysite/logs/accesslog.txt-www common

 

ServerAdmin [email protected]

DocumentRoot /home/mysite/forums

ServerName forums.mysite.com

ErrorLog /home/mysite/logs/errorlog.txt-forum

CustomLog /home/mysite/logs/accesslog.txt-forum common

 

ServerAdmin [email protected]

DocumentRoot /home/mysite/moodle

ServerName moodle.mysite.com

ErrorLog /home/mysite/logs/errorlog.txt-moodle

CustomLog /home/mysite/logs/accesslog.txt-moodle common

 

So anything that's not forums.mysite.com or moodle.mysite.com lands on the top vhost (mysite.com) so I can have mysite.com/images mysite.com/etc as well as having moodle.mysite.com/images being separate.

 

The logfiles are a pretty good idea too if you're building something and want to review the logs in a localised environment rather than for the whole box.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...