7

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?

13

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.

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

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>

1
  • 2
    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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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