logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: VirtualdocumentRoot and open_basedir Page 1, 2, 3  Next
Author
AMailer



Joined: 25 Sep 2006
Posts: 45
Location: Canada

PostPosted: Mon 25 Sep '06 22:56    Post subject: VirtualdocumentRoot and open_basedir Reply with quote

Hey,
I'm not sure if this has been addressed before and solved, but I was wondering if anyone knew a way to get the following setup working that allows open_basedir to recognize the %1
Code:
<VirtualHost *:80>

       ServerAdmin admin@localhost
      ServerName www.*.domain.com

       ServerAlias *.domain.com

       VirtualDocumentRoot "/home/httpd/html/domains/%1"
   php_admin_flag safe_mode on
        php_admin_value open_basedir /home/httpd/html/domains/%1
</VirtualHost>


I can't seem to get it to work, and Im not sure if its even possiable.

If this doesn't work, is there another way to allow me to setup subdomains easily without writing to a config file or restarting apache?

Thanks
P.S. I have perl installed too and I was wondering how I can make perl secure so that it cannot view files from other users on the network. With php I think open_basedir solves the problem.

If you could tell me how usually you would setup a subdomain system, it would be great.
Back to top
Jorge



Joined: 12 Mar 2006
Posts: 376
Location: Belgium

PostPosted: Tue 26 Sep '06 8:59    Post subject: Reply with quote

can't be done without aditional module.

If I'm sure though it will work with mod_macro!
Back to top
AMailer



Joined: 25 Sep 2006
Posts: 45
Location: Canada

PostPosted: Tue 26 Sep '06 13:07    Post subject: Reply with quote

Hey, is that macro module only for apache 2.2?
Back to top
Jorge



Joined: 12 Mar 2006
Posts: 376
Location: Belgium

PostPosted: Tue 26 Sep '06 13:42    Post subject: Reply with quote

No it works on 2.0 and 2.2 on Unix, Linux, Mac and windows Smile

if you google it you'll find it. 2.2 binaries are avaible here
Back to top
AMailer



Joined: 25 Sep 2006
Posts: 45
Location: Canada

PostPosted: Tue 26 Sep '06 19:16    Post subject: Reply with quote

Alright, will do.
But is this how normally subdomains are setup? Like...um professional subdomain sites? o.O How do they setup their subdomains?

I dont assume they write the full virtual hosts for each domain since, doesn't that require a restart of the server? O.o
Back to top
Steffen
Moderator


Joined: 15 Oct 2005
Posts: 3094
Location: Hilversum, NL, EU

PostPosted: Tue 26 Sep '06 19:24    Post subject: Reply with quote

Read also about mass virtual hosting at http://httpd.apache.org/docs/2.2/vhosts/mass.html

Steffen
Back to top
AMailer



Joined: 25 Sep 2006
Posts: 45
Location: Canada

PostPosted: Tue 26 Sep '06 21:52    Post subject: Reply with quote

Hey, I have read that before... I tried the:
Simple dynamic virtual hosts using mod_rewrite

But it doesn't work, I figure if that works, I can just write something like
php_admin_value open_basedir /www/hosts/${lowercase:%{SERVER_NAME}}/cgi-bin/$1

It should then work right? But anyhow, for some odd reason- even without adding that (the php_admin_value) the script doesn't work, the domains are not being ercognized, and i'm not seeing any errors in my error log.
Back to top
AMailer



Joined: 25 Sep 2006
Posts: 45
Location: Canada

PostPosted: Tue 26 Sep '06 22:10    Post subject: Reply with quote

For the macro mod, why can't I do this:
Code:
<Macro VHost $name $port>

<VirtualHost *:$port>

    ServerAdmin admin@localhost

    DocumentRoot "/home/httpd/html/domains/$name.domain.com"

    ServerName www.$name.domain.com

    ServerAlias $name.domain.com
    php_admin_value open_basedir "/home/httpd/html/domains/$name.domain.com

</VirtualHost>

</Macro>

Use VHost * 80


It doesn't recognize the * in the Use Host, how do I get that to work? I don't want to always restart my Apache :S
Back to top
Jorge



Joined: 12 Mar 2006
Posts: 376
Location: Belgium

PostPosted: Wed 27 Sep '06 9:26    Post subject: Reply with quote

Code:

NameVirtualHost *:80
NameVirtualHost *:443
<Macro vhost $sub $domain $admin>
    <VirtualHost $sub.$domain:80>
       ServerAdmin $admin
       DocumentRoot "/home/httpd/html/domains/$domain/$sub "
       ServerName $host
       php_admin_value open_basedir "/home/httpd/html/domains/$domain/$sub"
    </VirtualHost>
</Macro>


Code:
Use vhost www mydomain.com host@domain.com
Use vhost private mydomain.com host@domain.com


this will create 2 hosts

www.mydmain.com -> /home/httpd/html/domains/mydomain.com/www/
private.mydmain.com -> /home/httpd/html/domains/mydomain.com/private/

you just add another Use vhost blabla line to add a new one

you can create another macro vhostssl for example to create and ssl vhost (but here IP only so named hosting won't work there), heck you can even nest macro's!

For more example just ask... I'm very fond of mod macro
Back to top
AMailer



Joined: 25 Sep 2006
Posts: 45
Location: Canada

PostPosted: Wed 27 Sep '06 13:22    Post subject: Reply with quote

Yes, but after each addition, don't I have to restart Apache?
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Wed 27 Sep '06 13:55    Post subject: Reply with quote

Allways when you changed the httpd.conf you have to restart Apache. Not sure if that is a feature or a bug Wink
Back to top
AMailer



Joined: 25 Sep 2006
Posts: 45
Location: Canada

PostPosted: Wed 27 Sep '06 21:14    Post subject: Reply with quote

Hence, is there a way that I can get around doing that? Do professional web hosts restart their apache server after every new domai is added?
Back to top
Jorge



Joined: 12 Mar 2006
Posts: 376
Location: Belgium

PostPosted: Wed 27 Sep '06 23:45    Post subject: Reply with quote

Yes but if you do a -k restart all current request will be handle off before the restart... its barely noticable for the users.
Back to top
AMailer



Joined: 25 Sep 2006
Posts: 45
Location: Canada

PostPosted: Wed 27 Sep '06 23:51    Post subject: Reply with quote

Wouldn't the other way still be the best way? If so, what is it? (either way actually, what is it xD please)

Anyhow, what is a k restart? I use rc.d/httpd restart to restart my apache server (nvm :S got it... httpd -k restart)
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Thu 28 Sep '06 10:24    Post subject: Reply with quote

under *nix based systems you should use apachectl -k graceful to restart[/i]
Back to top
AMailer



Joined: 25 Sep 2006
Posts: 45
Location: Canada

PostPosted: Thu 28 Sep '06 21:47    Post subject: Reply with quote

So, web hosts (godaddy, dreamhost) they all use this method (they restart apache)? o.O
Back to top
Jorge



Joined: 12 Mar 2006
Posts: 376
Location: Belgium

PostPosted: Thu 28 Sep '06 22:58    Post subject: Reply with quote

AMailer wrote:
So, web hosts (godaddy, dreamhost) they all use this method (they restart apache)? o.O


They probebly have there own in the hows module to do vhosting.

Some restart yes, other use vhost_alias module for this but it more restrictive on securing php, and such
Back to top
AMailer



Joined: 25 Sep 2006
Posts: 45
Location: Canada

PostPosted: Fri 29 Sep '06 1:11    Post subject: Reply with quote

Oh, I see. Well intresting.

What language are the modules written in and is it possiable to get the source of the module that allows me to use php_ values in the httpd configs?
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Fri 29 Sep '06 9:37    Post subject: Reply with quote

The source is written in C. Source from the module to set php_values can be found at www.php.net Wink
Back to top
AMailer



Joined: 25 Sep 2006
Posts: 45
Location: Canada

PostPosted: Fri 29 Sep '06 12:48    Post subject: Reply with quote

Thanks a lot
Back to top


Reply to topic   Topic: VirtualdocumentRoot and open_basedir View previous topic :: View next topic
Post new topic   Forum Index -> Apache Page 1, 2, 3  Next