Web Development Thread, Apache and virtual hosts in Coding and Web Development; Ok I have Apache running fine and I am setting up various things on the server. The problem is I ...
-
7th August 2009, 11:05 AM #1 Apache and virtual hosts
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?
-
-
IDG Tech News
-
7th August 2009, 11:23 AM #2
-
2 Thanks to smadison:
TechMonkey (7th August 2009), ZeroHour (7th August 2009)
-
7th August 2009, 11:47 AM #3 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:
Code:
<VirtualHost _default_:*>
DocumentRoot /www/default
</VirtualHost>
to the virtual hosts file and all is well
Huzzah.
-
-
7th August 2009, 12:01 PM #4 Ok I lied, that just breaks everything. So I am back to square one, can't find anything in the virtual hosts docs. Any ideas?
-
-
7th August 2009, 12:44 PM #5 I am kinda lost as to what your doing.
What do you mean by every time you install something? e.g wha?
-
-
7th August 2009, 12:48 PM #6 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 www.mywebhost.com so stuff like 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 to kmount from:
TechMonkey (7th August 2009)
-
7th August 2009, 01:15 PM #7 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.
-
-
7th August 2009, 01:37 PM #8 Yep that did it. It was what I thought the solution above should have done. I now have:
Code:
<VirtualHost *:80>
DocumentRoot "{htdocs path}"
ServerName {ipaddress}
</VirtualHost> 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!
-
-
7th August 2009, 01:52 PM #9 I tend to do mine similarly but rather than IP I use names.
NameVirtualHost 1.2.3.4:80
<VirtualHost 1.2.3.4:80>
ServerAdmin
postmaster@mysite.com
DocumentRoot /home/mysite/www
ServerName mysite.com
ServerAlias
www.mysite.com
ErrorLog /home/mysite/logs/errorlog.txt-www
CustomLog /home/mysite/logs/accesslog.txt-www common
</VirtualHost>
<VirtualHost 1.2.3.4:80>
ServerAdmin
postmaster@mysite.com
DocumentRoot /home/mysite/forums
ServerName forums.mysite.com
ErrorLog /home/mysite/logs/errorlog.txt-forum
CustomLog /home/mysite/logs/accesslog.txt-forum common
</VirtualHost>
<VirtualHost 1.2.3.4:80>
ServerAdmin
postmaster@mysite.com
DocumentRoot /home/mysite/moodle
ServerName moodle.mysite.com
ErrorLog /home/mysite/logs/errorlog.txt-moodle
CustomLog /home/mysite/logs/accesslog.txt-moodle common
</VirtualHost>
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.
-
SHARE: 
Similar Threads
-
By reggiep in forum Virtual Learning Platforms
Replies: 1
Last Post: 1st June 2009, 01:50 PM
-
By gshaw in forum Thin Client and Virtual Machines
Replies: 3
Last Post: 17th December 2008, 06:04 PM
-
By FN-GM in forum How do you do....it?
Replies: 1
Last Post: 16th September 2008, 03:22 PM
-
By FN-GM in forum How do you do....it?
Replies: 6
Last Post: 30th May 2008, 08:18 PM
-
By Steven in forum Wireless Networks
Replies: 6
Last Post: 25th May 2008, 11:27 PM
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules