You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by jupiter <ju...@gmail.com> on 2012/10/26 12:02:11 UTC

[users@httpd] Set multiple DocumentRoot

Hi,

I need to set DocumentRoot to two directories, one for development and
one for testing. But the server has only one IP address, and there is
no DNS. Is it possible? If so, please give an example.

Thank you.

Kind regards,

j

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Set multiple DocumentRoot

Posted by Pete Houston <ph...@openstrike.co.uk>.
On Sun, Oct 28, 2012 at 04:04:36PM +1100, jupiter wrote:
> <VirtualHost *:80>
>     ServerName 192.168.1.101
>     DocumentRoot /tmp
> </VirtualHost>
> 
> The 8080 works, but 80 got an error of "Permission denied: file
> permissions deny server access: /tmp/index.html". I don't see any
> permission problems:

Apache may be prevented from directly accessing /tmp by another security
layer such as SELinux or AppArmor. Having /tmp as a DcoumentRoot is
almost never a good idea, so why not make your second DocumentRoot
/var/www/html2 for example?

Also, you don't need those NameVirtualHost directives because as you
stated in the original post you are not using name-based virtual
hosting.

Pete
-- 
Openstrike - improving business through open source
http://www.openstrike.co.uk/ or call 01722 770036 / 07092 020107

Re: [users@httpd] Set multiple DocumentRoot

Posted by jupiter <ju...@gmail.com>.
Thanks for all responses.

I've tried first suggestion to use 80 and 8080 as following set up:

Listen 8080
Listen 80

NameVirtualHost *:80
NameVirtualHost *:8080

<VirtualHost *:8080>
    ServerName 192.168.1.101
    DocumentRoot /var/www/html/
</VirtualHost>

<VirtualHost *:80>
    ServerName 192.168.1.101
    DocumentRoot /tmp
</VirtualHost>

The 8080 works, but 80 got an error of "Permission denied: file
permissions deny server access: /tmp/index.html". I don't see any
permission problems:

[tmp]$ ls -l index.html
-rwxr-xr-x. 1 apache apache 27 Oct 28 15:48 index.html

On 10/26/12, Pete Houston <ph...@openstrike.co.uk> wrote:
> On Fri, Oct 26, 2012 at 08:02:11PM +1000, jupiter wrote:
>> I need to set DocumentRoot to two directories, one for development and
>> one for testing. But the server has only one IP address, and there is
>> no DNS. Is it possible? If so, please give an example.
>
> Use different ports. You can set up two virtual hosts, eg. one on port 80
> for testing and one on port 8080 for development.
>
> Pete
> --
> Openstrike - improving business through open source
> http://www.openstrike.co.uk/ or call 01722 770036 / 07092 020107
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Set multiple DocumentRoot

Posted by Pete Houston <ph...@openstrike.co.uk>.
On Fri, Oct 26, 2012 at 08:02:11PM +1000, jupiter wrote:
> I need to set DocumentRoot to two directories, one for development and
> one for testing. But the server has only one IP address, and there is
> no DNS. Is it possible? If so, please give an example.

Use different ports. You can set up two virtual hosts, eg. one on port 80
for testing and one on port 8080 for development.

Pete
-- 
Openstrike - improving business through open source
http://www.openstrike.co.uk/ or call 01722 770036 / 07092 020107

Re: [users@httpd] Set multiple DocumentRoot

Posted by Terry Carmen <te...@cnysupport.com>.
On 10/26/2012 06:02 AM, jupiter wrote:
> Hi,
>
> I need to set DocumentRoot to two directories, one for development and
> one for testing. But the server has only one IP address, and there is
> no DNS. Is it possible? If so, please give an example.

You can use multiple virtualhosts on one IP address by creating the 
directories:

/var/www/html/prod.example.com
/var/www/html/dev.example.com

And configuring your http.conf file with:

UseCanonicalName Off
VirtualDocumentRoot /var/www/html/%0

You can add the two hosts to your /etc/hosts file to make them resolve 
properly from your machine, if you can't update DNS.

Example: /etc/hosts

127.0.0.1   localhost
123.123.123.123 dev.example.com dev
123.123.123.123 prod.example.com prod


Terry



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org