Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm hosting my website on my own server running OSX 10.6.6. I have the main site up all fine with www2.chrislrobinson.co.uk pointing to my IP address (and hence the /Library/WebServer/Documents/ directory). My blog is located at www2.chrislrobinson.co.uk/blog but I would like to add to access it through blog.chrislrobinson.co.uk. My understanding is that I need to enable virtual hosts but I can't seem to get it to work properly.

So far, I've enabled the virtual host bit in /private/etc/apache2/httpd.conf. I've added

<VirtualHost *:80>
DocumentRoot "Library/WebServer/Documents/blog"
ServerName blog.chrislrobinson.co.uk
</VirtualHost>

to /private/etc/apache2/extra/httpd-vhosts.conf and

127.0.0.1 blog.chrislrobinson.co.uk

to /private/etc/hosts. After restarting apache, not only does blog.chrislrobinson.co.uk not work, but I get the message

Forbidden You don't have permission to access /blog/ on this server.

I'd appreciate any help you guys can give. Thanks Chris

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

Check your httpd.conf for your Allow/Deny permissions. You probably need to add a <Directory /Library/Webserver/Documents/blog> directive within the VirtualHost to allow accessibility.

Also, you're missing your leading / in the VirtualHost path.

share|improve this answer
    
Thanks for that. My user/group are both set to _www and everything now seems to work when I set the ServerName line in httpd.conf to www2.chrislrobinson.co.uk:80. However, using the above settings (albeit with the corrected leading /), blog.chrislrobinson.co.uk directs me to www2.chrislrobinson.co.uk (or /Library/WebServer/Documents). Am I still doing something wrong? –  Chris Robinson Jan 26 '11 at 8:41
    
I assume in your vhosts.conf you have added/uncommented 'NameVirtualHost *', correct? You could try moving ww2.chrislrobinson.co.uk to a vhost as well to see if it continues to override blog. –  M. Early Jan 26 '11 at 20:32
add comment

you should use Server Admin for such a task. The reason is that it's not easier or better but if you make any changes from the command line, you will get Server Admin GUI out of sync with the real status of the configuration. To solve your problem use Redirect Directive. More info is here:

http://stackoverflow.com/questions/2575259/apache-redirect-blog-foobar-com-to-www-foobar-com

share|improve this answer
    
Sorry I should mentioned that I am running 10.6.6 client, not server. Can you recommend another GUI for server admin? –  Chris Robinson Jan 26 '11 at 10:01
    
Oh, I was confused from your original post. Follow the link I sent you if you want to go the command line way. Otherwise install a control panel like Webmin, Plesk etc. Just google for it –  BobC Jan 26 '11 at 12:11
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.