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.

For example, say I have my htdocs in:

~/public_html

and those documents are being served on port 80. Is there any way to make apache server documents in:

~/public_html/something

on a different port? Or does that require a separate instance of apache?

share|improve this question
add comment

2 Answers 2

up vote 12 down vote accepted

It requires a different virtual host.

Just set up two virtual hosts that listen on different ports, let the second have a different document root and forbid access to 'something' within the first.

share|improve this answer
    
+1 correct - you just need a new vhost with a different docroot –  Coops Aug 4 '09 at 20:15
    
Thanks! I'd vote up, but need 15 reputation before I can. –  Mike Trpcic Aug 4 '09 at 20:16
1  
2013 comment!!! –  David Houde May 3 '13 at 11:32
add comment

Sure, first you'll have to set apache to listen on two ports. So in your httpd.conf set

Listen 80

Listen 8080

Then create two vhost configurations (/etc/apache/sites-enabled/000-default). The first can be *:80 and the second *:8080. Set the respective DocumentRoots.

<VirtualHost *:80>

DocumentRoot ~/public_html

Blah Blah....

</VirtualHost>

and...

<VirtualHost *:8080>

DocumentRoot ~/public_html/something

Blah Blah....

</VirtualHost>

share|improve this answer
    
Wow, you took Manni's answer a step further. Thanks for the example config stuff, it's very helpful. Sorry I can't upvote, but I will when I get 15 reputation! –  Mike Trpcic Aug 4 '09 at 20:17
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.