Author |
|
AMailer
Joined: 25 Sep 2006 Posts: 45 Location: Canada
|
Posted: Mon 25 Sep '06 22:56 Post subject: VirtualdocumentRoot and open_basedir |
|
|
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
|
Posted: Tue 26 Sep '06 8:59 Post subject: |
|
|
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
|
Posted: Tue 26 Sep '06 13:07 Post subject: |
|
|
Hey, is that macro module only for apache 2.2? |
|
Back to top |
|
Jorge
Joined: 12 Mar 2006 Posts: 376 Location: Belgium
|
Posted: Tue 26 Sep '06 13:42 Post subject: |
|
|
No it works on 2.0 and 2.2 on Unix, Linux, Mac and windows
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
|
Posted: Tue 26 Sep '06 19:16 Post subject: |
|
|
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: 3092 Location: Hilversum, NL, EU
|
|
Back to top |
|
AMailer
Joined: 25 Sep 2006 Posts: 45 Location: Canada
|
Posted: Tue 26 Sep '06 21:52 Post subject: |
|
|
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
|
Posted: Tue 26 Sep '06 22:10 Post subject: |
|
|
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
|
Posted: Wed 27 Sep '06 9:26 Post subject: |
|
|
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>
|
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
|
Posted: Wed 27 Sep '06 13:22 Post subject: |
|
|
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
|
Posted: Wed 27 Sep '06 13:55 Post subject: |
|
|
Allways when you changed the httpd.conf you have to restart Apache. Not sure if that is a feature or a bug |
|
Back to top |
|
AMailer
Joined: 25 Sep 2006 Posts: 45 Location: Canada
|
Posted: Wed 27 Sep '06 21:14 Post subject: |
|
|
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
|
Posted: Wed 27 Sep '06 23:45 Post subject: |
|
|
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
|
Posted: Wed 27 Sep '06 23:51 Post subject: |
|
|
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
|
Posted: Thu 28 Sep '06 10:24 Post subject: |
|
|
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
|
Posted: Thu 28 Sep '06 21:47 Post subject: |
|
|
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
|
Posted: Thu 28 Sep '06 22:58 Post subject: |
|
|
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
|
Posted: Fri 29 Sep '06 1:11 Post subject: |
|
|
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
|
Posted: Fri 29 Sep '06 9:37 Post subject: |
|
|
The source is written in C. Source from the module to set php_values can be found at www.php.net |
|
Back to top |
|
AMailer
Joined: 25 Sep 2006 Posts: 45 Location: Canada
|
Posted: Fri 29 Sep '06 12:48 Post subject: |
|
|
Thanks a lot |
|
Back to top |
|