You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Stephan von Krawczynski <sk...@ithnet.com> on 2004/08/26 15:32:21 UTC
[users@httpd] How to run php with virtual host based uid/gid on apache2 ?
Hello all,
I tried to find an answer for this question for quite some time, but it seems
no real solutions are present at this time.
Consider having a setup with around 2000 virtual hosts (with low average
traffic) on linux. Using suexec to provide uid/gid for CGI scripts works very
well. Only real security issue is php as it runs with apache default uid/gid.
How can one change that?
Using MPM perchild is not really an option, as it runs at least one client per
existing vhost (if I got that right) which is not really efficient for virtual
hosts that have possibly one or two requests a day, and considering the number.
I really would like to have some possibility to run php scripts with a
virtual-host based uid/gid just like suexec. Is that possible at all?
Regards,
Stephan
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] How to run php with virtual host based uid/gid
on apache2 ?
Posted by Matthew Pitts <in...@nvinity.net>.
Thanks for the response and sorry for the lack for clarification.
By 'managing it all' I mean the launching of Apache processes using command line arguments to set
runtime options such as User, Group, ServerName, DocumentRoot, modules to load, etc. Of course,
this allows for the inclusion of fastcgi if you so desire :-).
Thanks for the info. on shared memory. Is there a way to determine amoung many httpd processes
what, if any, memory is shared? My printout from ps shows about 20MB of memory usage for each
parent and child; at least I think that's right.
Thanks,
Matt Pitts
> I guess you mean one apache server for each individual UID, right? If yes, I
> guess the impact would be in the memory usage. In theory, any shared object
> opened with mmap(), should be shared in memory between all processes using
> the library. But this seems to be very platform dependent, and people don't
> recommend to rely on the fact that SOs are going to be shared if they have
> different parents. This information I got from the freebsd developers
> mailing list, and of course, I mean memory shared between two processes that
> have nothing to do with each other... Of course, mod_php.so would be shared
> between apache processes that have the same parent. But I'm not sure it
> would be shared between 2 sets of apache processes, each set spawned by a
> different parent (like running two httpd severs with different conf files).
>
> If someone knows this, please enlighten us :)
>
> When you say your perl package manages it all, I'm not sure if you mean it
> manages running individual apache servers under different UIDs, or the
> fastcgi stuff I described. Which one?
>
> Take care ;)
>
>
> ----- Original Message -----
> From: "Matthew Pitts" <in...@nvinity.net>
> To: <us...@httpd.apache.org>
> Sent: Thursday, August 26, 2004 10:10 AM
> Subject: Re: [users@httpd] How to run php with virtual host based uid/gid on
> apache2 ?
>
>
>> What is the impact of running individual Apache processes in this
>> situation? Obviously, would be able to tailor each server's modules and
>> uid/gid seperately. I've been working on something like this with a PERL
>> package to manage it all; is this a practical thing to do for a low
>> traffic server?
>>
>> Thanks,
>> Matt Pitts
>>
>> > There is a huge performance impact when running php as cgi... Usually
> php
>> > binaries are big (11 mb in my case), and spawning a new child, exec() a
>> > php
>> > process, and compiling the script everytime a php page is called is a
>> > real
>> > pain for your CPU (and response time for your users).
>> >
>> > I am testing fastcgi with php. Running the static php/fastcgi server
>> > requires at least 2 php processes per UID (1 parent and 1 child), so
> this
>> > is
>> > out of question because it would use lots of memory (you'd be better
> off
>> > running many instances of apache, each under a different UID).
>> > So, you could run the dynamic version of php/fastcgi. Whenever a php
>> > script
>> > is called for the first time under a UID, fastcgi spawns the php
> processes
>> > (speed similar to normal cgi), and then they stay alive serving
> subsequent
>> > requests (speed very similar to the module). If these processes are not
>> > being used for a configurable time, they die off. Basically, you'd
> avoid
>> > exec() php everytime a php script is called. The drawback is that for
> 2000
>> > vhosts, you'd never know which site is is gonna use php, and how often,
> so
>> > very hard to calculate the memory you gonna use, and the impact this
> would
>> > have in the server.
>> > The good thing is that you could do this for your perl, python, tcl, etc
>> > scripts as well. I'm having a hard time creating a parent (wrapper)
>> > process
>> > for perl though. If someone with more perl skills than myself want to
> join
>> > this, just let me know...
>> >
>> > cheers
>> >
>> >
>> > ----- Original Message -----
>> > From: "Robert Andersson" <ro...@profundis.nu>
>> > To: <us...@httpd.apache.org>
>> > Sent: Thursday, August 26, 2004 6:39 AM
>> > Subject: Re: [users@httpd] How to run php with virtual host based
> uid/gid
>> > on
>> > apache2 ?
>> >
>> >
>> >> Stephan von Krawczynski wrote:
>> >> > Consider having a setup with around 2000 virtual hosts (with low
>> >> average
>> >> > traffic) on linux. Using suexec to provide uid/gid for CGI scripts
>> >> works
>> >> very
>> >> > well. Only real security issue is php as it runs with apache default
>> >> uid/gid.
>> >> > How can one change that?
>> >>
>> >> Your best bet is to run PHP as CGI (through SuExec, of course).
>> >>
>> >> There are also some "safe options" in PHP that limits its permissions
>> > (what
>> >> can be executed, files that can be written etc), but I'm not very
>> >> familiar
>> >> with securing PHP that way. You could probably read something about
> this
>> > in
>> >> PHP's docs.
>> >>
>> >> You cannot get the module version of PHP to serve requests under
>> >> different
>> >> uid/gid without using the perchild MPM; which sadly isn't an option
>> > anyway.
>> >>
>> >> Regards,
>> >> Robert Andersson
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> The official User-To-User support forum of the Apache HTTP Server
>> >> Project.
>> >> See <URL:http://httpd.apache.org/userslist.html> for more info.
>> >> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>> >> " from the digest: users-digest-unsubscribe@httpd.apache.org
>> >> For additional commands, e-mail: users-help@httpd.apache.org
>> >>
>> >
>> >
>> > ---------------------------------------------------------------------
>> > The official User-To-User support forum of the Apache HTTP Server
> Project.
>> > See <URL:http://httpd.apache.org/userslist.html> for more info.
>> > To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>> > " from the digest: users-digest-unsubscribe@httpd.apache.org
>> > For additional commands, e-mail: users-help@httpd.apache.org
>> >
>> >
>>
>>
>> ---------------------------------------------------------------------
>> The official User-To-User support forum of the Apache HTTP Server Project.
>> See <URL:http://httpd.apache.org/userslist.html> for more info.
>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>> " from the digest: users-digest-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
>
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] How to run php with virtual host based uid/gid on
apache2 ?
Posted by "Gustavo A. Baratto" <gb...@superb.net>.
I guess you mean one apache server for each individual UID, right? If yes, I
guess the impact would be in the memory usage. In theory, any shared object
opened with mmap(), should be shared in memory between all processes using
the library. But this seems to be very platform dependent, and people don't
recommend to rely on the fact that SOs are going to be shared if they have
different parents. This information I got from the freebsd developers
mailing list, and of course, I mean memory shared between two processes that
have nothing to do with each other... Of course, mod_php.so would be shared
between apache processes that have the same parent. But I'm not sure it
would be shared between 2 sets of apache processes, each set spawned by a
different parent (like running two httpd severs with different conf files).
If someone knows this, please enlighten us :)
When you say your perl package manages it all, I'm not sure if you mean it
manages running individual apache servers under different UIDs, or the
fastcgi stuff I described. Which one?
Take care ;)
----- Original Message -----
From: "Matthew Pitts" <in...@nvinity.net>
To: <us...@httpd.apache.org>
Sent: Thursday, August 26, 2004 10:10 AM
Subject: Re: [users@httpd] How to run php with virtual host based uid/gid on
apache2 ?
> What is the impact of running individual Apache processes in this
> situation? Obviously, would be able to tailor each server's modules and
> uid/gid seperately. I've been working on something like this with a PERL
> package to manage it all; is this a practical thing to do for a low
> traffic server?
>
> Thanks,
> Matt Pitts
>
> > There is a huge performance impact when running php as cgi... Usually
php
> > binaries are big (11 mb in my case), and spawning a new child, exec() a
> > php
> > process, and compiling the script everytime a php page is called is a
> > real
> > pain for your CPU (and response time for your users).
> >
> > I am testing fastcgi with php. Running the static php/fastcgi server
> > requires at least 2 php processes per UID (1 parent and 1 child), so
this
> > is
> > out of question because it would use lots of memory (you'd be better
off
> > running many instances of apache, each under a different UID).
> > So, you could run the dynamic version of php/fastcgi. Whenever a php
> > script
> > is called for the first time under a UID, fastcgi spawns the php
processes
> > (speed similar to normal cgi), and then they stay alive serving
subsequent
> > requests (speed very similar to the module). If these processes are not
> > being used for a configurable time, they die off. Basically, you'd
avoid
> > exec() php everytime a php script is called. The drawback is that for
2000
> > vhosts, you'd never know which site is is gonna use php, and how often,
so
> > very hard to calculate the memory you gonna use, and the impact this
would
> > have in the server.
> > The good thing is that you could do this for your perl, python, tcl, etc
> > scripts as well. I'm having a hard time creating a parent (wrapper)
> > process
> > for perl though. If someone with more perl skills than myself want to
join
> > this, just let me know...
> >
> > cheers
> >
> >
> > ----- Original Message -----
> > From: "Robert Andersson" <ro...@profundis.nu>
> > To: <us...@httpd.apache.org>
> > Sent: Thursday, August 26, 2004 6:39 AM
> > Subject: Re: [users@httpd] How to run php with virtual host based
uid/gid
> > on
> > apache2 ?
> >
> >
> >> Stephan von Krawczynski wrote:
> >> > Consider having a setup with around 2000 virtual hosts (with low
> >> average
> >> > traffic) on linux. Using suexec to provide uid/gid for CGI scripts
> >> works
> >> very
> >> > well. Only real security issue is php as it runs with apache default
> >> uid/gid.
> >> > How can one change that?
> >>
> >> Your best bet is to run PHP as CGI (through SuExec, of course).
> >>
> >> There are also some "safe options" in PHP that limits its permissions
> > (what
> >> can be executed, files that can be written etc), but I'm not very
> >> familiar
> >> with securing PHP that way. You could probably read something about
this
> > in
> >> PHP's docs.
> >>
> >> You cannot get the module version of PHP to serve requests under
> >> different
> >> uid/gid without using the perchild MPM; which sadly isn't an option
> > anyway.
> >>
> >> Regards,
> >> Robert Andersson
> >>
> >>
> >> ---------------------------------------------------------------------
> >> The official User-To-User support forum of the Apache HTTP Server
> >> Project.
> >> See <URL:http://httpd.apache.org/userslist.html> for more info.
> >> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> >> " from the digest: users-digest-unsubscribe@httpd.apache.org
> >> For additional commands, e-mail: users-help@httpd.apache.org
> >>
> >
> >
> > ---------------------------------------------------------------------
> > The official User-To-User support forum of the Apache HTTP Server
Project.
> > See <URL:http://httpd.apache.org/userslist.html> for more info.
> > To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> > " from the digest: users-digest-unsubscribe@httpd.apache.org
> > For additional commands, e-mail: users-help@httpd.apache.org
> >
> >
>
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] How to run php with virtual host based uid/gid
on apache2 ?
Posted by Matthew Pitts <in...@nvinity.net>.
What is the impact of running individual Apache processes in this
situation? Obviously, would be able to tailor each server's modules and
uid/gid seperately. I've been working on something like this with a PERL
package to manage it all; is this a practical thing to do for a low
traffic server?
Thanks,
Matt Pitts
> There is a huge performance impact when running php as cgi... Usually php
> binaries are big (11 mb in my case), and spawning a new child, exec() a
> php
> process, and compiling the script everytime a php page is called is a
> real
> pain for your CPU (and response time for your users).
>
> I am testing fastcgi with php. Running the static php/fastcgi server
> requires at least 2 php processes per UID (1 parent and 1 child), so this
> is
> out of question because it would use lots of memory (you'd be better off
> running many instances of apache, each under a different UID).
> So, you could run the dynamic version of php/fastcgi. Whenever a php
> script
> is called for the first time under a UID, fastcgi spawns the php processes
> (speed similar to normal cgi), and then they stay alive serving subsequent
> requests (speed very similar to the module). If these processes are not
> being used for a configurable time, they die off. Basically, you'd avoid
> exec() php everytime a php script is called. The drawback is that for 2000
> vhosts, you'd never know which site is is gonna use php, and how often, so
> very hard to calculate the memory you gonna use, and the impact this would
> have in the server.
> The good thing is that you could do this for your perl, python, tcl, etc
> scripts as well. I'm having a hard time creating a parent (wrapper)
> process
> for perl though. If someone with more perl skills than myself want to join
> this, just let me know...
>
> cheers
>
>
> ----- Original Message -----
> From: "Robert Andersson" <ro...@profundis.nu>
> To: <us...@httpd.apache.org>
> Sent: Thursday, August 26, 2004 6:39 AM
> Subject: Re: [users@httpd] How to run php with virtual host based uid/gid
> on
> apache2 ?
>
>
>> Stephan von Krawczynski wrote:
>> > Consider having a setup with around 2000 virtual hosts (with low
>> average
>> > traffic) on linux. Using suexec to provide uid/gid for CGI scripts
>> works
>> very
>> > well. Only real security issue is php as it runs with apache default
>> uid/gid.
>> > How can one change that?
>>
>> Your best bet is to run PHP as CGI (through SuExec, of course).
>>
>> There are also some "safe options" in PHP that limits its permissions
> (what
>> can be executed, files that can be written etc), but I'm not very
>> familiar
>> with securing PHP that way. You could probably read something about this
> in
>> PHP's docs.
>>
>> You cannot get the module version of PHP to serve requests under
>> different
>> uid/gid without using the perchild MPM; which sadly isn't an option
> anyway.
>>
>> Regards,
>> Robert Andersson
>>
>>
>> ---------------------------------------------------------------------
>> The official User-To-User support forum of the Apache HTTP Server
>> Project.
>> See <URL:http://httpd.apache.org/userslist.html> for more info.
>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>> " from the digest: users-digest-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
>
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] How to run php with virtual host based uid/gid on
apache2 ?
Posted by "Gustavo A. Baratto" <gb...@superb.net>.
There is a huge performance impact when running php as cgi... Usually php
binaries are big (11 mb in my case), and spawning a new child, exec() a php
process, and compiling the script everytime a php page is called is a real
pain for your CPU (and response time for your users).
I am testing fastcgi with php. Running the static php/fastcgi server
requires at least 2 php processes per UID (1 parent and 1 child), so this is
out of question because it would use lots of memory (you'd be better off
running many instances of apache, each under a different UID).
So, you could run the dynamic version of php/fastcgi. Whenever a php script
is called for the first time under a UID, fastcgi spawns the php processes
(speed similar to normal cgi), and then they stay alive serving subsequent
requests (speed very similar to the module). If these processes are not
being used for a configurable time, they die off. Basically, you'd avoid
exec() php everytime a php script is called. The drawback is that for 2000
vhosts, you'd never know which site is is gonna use php, and how often, so
very hard to calculate the memory you gonna use, and the impact this would
have in the server.
The good thing is that you could do this for your perl, python, tcl, etc
scripts as well. I'm having a hard time creating a parent (wrapper) process
for perl though. If someone with more perl skills than myself want to join
this, just let me know...
cheers
----- Original Message -----
From: "Robert Andersson" <ro...@profundis.nu>
To: <us...@httpd.apache.org>
Sent: Thursday, August 26, 2004 6:39 AM
Subject: Re: [users@httpd] How to run php with virtual host based uid/gid on
apache2 ?
> Stephan von Krawczynski wrote:
> > Consider having a setup with around 2000 virtual hosts (with low average
> > traffic) on linux. Using suexec to provide uid/gid for CGI scripts works
> very
> > well. Only real security issue is php as it runs with apache default
> uid/gid.
> > How can one change that?
>
> Your best bet is to run PHP as CGI (through SuExec, of course).
>
> There are also some "safe options" in PHP that limits its permissions
(what
> can be executed, files that can be written etc), but I'm not very familiar
> with securing PHP that way. You could probably read something about this
in
> PHP's docs.
>
> You cannot get the module version of PHP to serve requests under different
> uid/gid without using the perchild MPM; which sadly isn't an option
anyway.
>
> Regards,
> Robert Andersson
>
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] How to run php with virtual host based uid/gid on apache2 ?
Posted by Robert Andersson <ro...@profundis.nu>.
Stephan von Krawczynski wrote:
> > I did a quick test (with Apache 2), like this:
> > - I put a copy of the php binary in a web root.
> > - Had the above AddType and Action, but with "/php" as second
> > parameter.
>
> I tried that again under 1.3.28 but no good. It still tries to find a
> file "/php/test.php" which is wrong.
Hmm... I don't know if this might be a 1.3 vs. 2.0 issue, or just a config
issue. I haven't played much with Action, so I don't really why this
happens. Could you perhaps post the *exact* configuration you tried?
Unless I'm wrong, what should happen is that a request to eg "/page.php"
gets internally redirected to something like "/php?page.php" (simplified).
The CGI "/php" is then executed with "page.php" as argument.
> How can apache see from above config that it should use my CGI-wrapper
> suexec for the above case, that ".php" should be treated just like ".cgi"
(as an
> example) only with using "/usr/bin/php" as interpreter?
I'm actually not 100% certain, but when doing this, "/usr/bin/php" is not
the interpreter, but the CGI program itself. Thus it should be executed as
any other CGI, in this case, through SuExec.
I had no idea running PHP as CGI would be so complicated! ;-)
Regards,
Robert Andersson
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] How to run php with virtual host based uid/gid on
apache2 ?
Posted by Stephan von Krawczynski <sk...@ithnet.com>.
On Fri, 27 Aug 2004 12:42:17 +0200
"Robert Andersson" <ro...@profundis.nu> wrote:
> Stephan von Krawczynski wrote:
> > > AddType application/x-httpd-php .php
> > > Action application/x-httpd-php "/usr/bin/php"
> >
> > I tried that with Apache 1.3 (for a test), but apache tried to execute
> > "/usr/bin/php/<myscript.php>" then, which obviously failed.
> > I guess I forgot something obvious, can you please give an additional
> > advise
>
> Seems like I missled you; Action takes a URI not a system path.
>
> I did a quick test (with Apache 2), like this:
> - I put a copy of the php binary in a web root.
> - Had the above AddType and Action, but with "/php" as second
> parameter.
I tried that again under 1.3.28 but no good. It still tries to find a
file "/php/test.php" which is wrong.
>
> When requesting a .php file, it was parsed through CGI. However, some ENVs
> gets screwed up (eg. SCRIPT_FILENAME), so perhaps it might be good to make a
> wrapper.
>
> In a mass-vhost situation, you might be able to do something like this:
>
> Alias /php-cgi /usr/bin/php
> AddType application/x-httpd-php .php
> Action application/x-httpd-php /php-cgi
Tried that too and apache tried to find
"/php-cgi/test.php" after that, so no success.
> The alias would allow you to not have to put a copy/symlink to PHP in each
> vhost's document root.
That surely would be great. The only thing I do not understand (and my apache
obviously neither):
How can apache see from above config that it should use my CGI-wrapper suexec
for the above case, that ".php" should be treated just like ".cgi" (as an
example) only with using "/usr/bin/php" as interpreter?
I googled around a bit and found out most people think your "AddType/Action"
idea should work, which seems to show that they actually did never test that,
at least not under unix/linux.
Regards,
Stephan
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] How to run php with virtual host based uid/gid on apache2 ?
Posted by Robert Andersson <ro...@profundis.nu>.
Stephan von Krawczynski wrote:
> > AddType application/x-httpd-php .php
> > Action application/x-httpd-php "/usr/bin/php"
>
> I tried that with Apache 1.3 (for a test), but apache tried to execute
> "/usr/bin/php/<myscript.php>" then, which obviously failed.
> I guess I forgot something obvious, can you please give an additional
> advise
Seems like I missled you; Action takes a URI not a system path.
I did a quick test (with Apache 2), like this:
- I put a copy of the php binary in a web root.
- Had the above AddType and Action, but with "/php" as second
parameter.
When requesting a .php file, it was parsed through CGI. However, some ENVs
gets screwed up (eg. SCRIPT_FILENAME), so perhaps it might be good to make a
wrapper.
In a mass-vhost situation, you might be able to do something like this:
Alias /php-cgi /usr/bin/php
AddType application/x-httpd-php .php
Action application/x-httpd-php /php-cgi
The alias would allow you to not have to put a copy/symlink to PHP in each
vhost's document root.
Note, I have the feeling that there is a much simpler/better way to this,
but nothing comes to mind.
Regards,
Robert Andersson
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] How to run php with virtual host based uid/gid on
apache2 ?
Posted by Stephan von Krawczynski <sk...@ithnet.com>.
On Thu, 26 Aug 2004 17:08:30 +0200
"Robert Andersson" <ro...@profundis.nu> wrote:
> Stephan von Krawczynski wrote:
> > > Your best bet is to run PHP as CGI (through SuExec, of course).
> >
> > Well, if I got that right this isn't really an option, because you have to
> > change the php-scripts for that (include "#! /.../php" on top).
>
> I have not tested it myself, but you should be able to do something like:
>
> AddType application/x-httpd-php .php
> Action application/x-httpd-php "/usr/bin/php"
I tried that with Apache 1.3 (for a test), but apache tried to execute
"/usr/bin/php/<myscript.php>" then, which obviously failed.
I guess I forgot something obvious, can you please give an additional advise
...
Regards,
Stephan
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] How to run php with virtual host based uid/gid on apache2 ?
Posted by Robert Andersson <ro...@profundis.nu>.
Stephan von Krawczynski wrote:
> > Your best bet is to run PHP as CGI (through SuExec, of course).
>
> Well, if I got that right this isn't really an option, because you have to
> change the php-scripts for that (include "#! /.../php" on top).
I have not tested it myself, but you should be able to do something like:
AddType application/x-httpd-php .php
Action application/x-httpd-php "/usr/bin/php"
If not, there are numerous other more or less ugly ways to achieve it.
> > You cannot get the module version of PHP to serve requests under
> > different uid/gid without using the perchild MPM; which sadly isn't an
> > option anyway.
>
> Well, maybe it could be if something is done about the existing problems?
Problem is, that in order to run under different uid/gid, a new processes
must be forked (as with SuExec/CGI). This feature is long wanted, but the
"only" solution is the perchild MPM, which (pre)forks a process for each
uid/gid. However, AFAIK the development goes very slow, to say the least. It
really is a nasty problem.
I'll just say it again. It is currently not possible to serve a specific
request under a specific uid/gid, unless you somehow fork a new process
(read: CGI).
Regards,
Robert Andersson
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] How to run php with virtual host based uid/gid on
apache2 ?
Posted by Stephan von Krawczynski <sk...@ithnet.com>.
On Thu, 26 Aug 2004 15:39:59 +0200
"Robert Andersson" <ro...@profundis.nu> wrote:
> Stephan von Krawczynski wrote:
> > Consider having a setup with around 2000 virtual hosts (with low average
> > traffic) on linux. Using suexec to provide uid/gid for CGI scripts works
> very
> > well. Only real security issue is php as it runs with apache default
> uid/gid.
> > How can one change that?
>
> Your best bet is to run PHP as CGI (through SuExec, of course).
Well, if I got that right this isn't really an option, because you have to
change the php-scripts for that (include "#! /.../php" on top).
You cannot really explain that to several hundred people knowing that most of
them use php stuff they don't understand themselves.
> There are also some "safe options" in PHP that limits its permissions (what
> can be executed, files that can be written etc), but I'm not very familiar
> with securing PHP that way. You could probably read something about this in
> PHP's docs.
Not a real good option either. I checked that several times.
> You cannot get the module version of PHP to serve requests under different
> uid/gid without using the perchild MPM; which sadly isn't an option anyway.
Well, maybe it could be if something is done about the existing problems?
Regards,
Stephan
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
RE: [users@httpd] Two level access using Basic Authentication
Posted by Mark McCulligh <mm...@visualtech.ca>.
Thanks for finding my syntax error.
I forgot it had to be the absolute path to the folder on the server, not the
path from the root on the site.
Mark.
-----Original Message-----
From: Joshua Slive [mailto:jslive@gmail.com]
Sent: Thursday, August 26, 2004 10:10 AM
To: users@httpd.apache.org
Subject: Re: [users@httpd] Two level access using Basic Authentication
On Thu, 26 Aug 2004 10:05:09 -0400, Mark McCulligh
<mm...@visualtech.ca> wrote:
> <Directory /private>
It is highly unlikely that you have a folder named "private" off the
root of your filesystem. More likely, you want to have <Directory
/usr/local/apache2/htdocs/private> or something like that.
Joshua.
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Best way to set up a password protected website for individual users
Posted by James Hughbanks <ja...@mikro-data.net>.
use .htaccess, have something like
AuthUserFile /home/blah/.htpasswd
AuthName "Password Required"
AuthType Basic
require valid-user
Then create your .htpasswd file by
htpasswd -c .htpasswd username
<prompts for password twice>
As you need to add passwords just omit the -c
htpasswd .htpasswd username
BTW htpasswd is a program included in apache, so if you have it
somewhere not in your path you might have to do
/usr/local/apache/bin/htpasswd
--James Hughbanks
Mikro-Data Engineering Dept.
support@mikro-data.net
1-866-457-6287
http://www.mikro-data.net
On Aug 27, 2004, at 10:41 PM, mbastreak wrote:
> As I have written in the subject line above, I am trying to establish
> the
> most productive an d easy solution to manage a website for about 15
> users(going to increase eventually several months down the road). I
> know
> about using a .htaccess file, but I was hoping to setup a username
> list so
> each user would have their own password. We are not too concerned about
> security as this is not really protecting anything serious just some
> information that should only be available to certain users. Any
> suggestions.
>
> OS: Gentoo Linux 2.4
> Apache: 2.0.50
>
> Patrick O'Neal
>
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server
> Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>
[users@httpd] Best way to set up a password protected website for individual users
Posted by mbastreak <mb...@awofm.info>.
As I have written in the subject line above, I am trying to establish the
most productive an d easy solution to manage a website for about 15
users(going to increase eventually several months down the road). I know
about using a .htaccess file, but I was hoping to setup a username list so
each user would have their own password. We are not too concerned about
security as this is not really protecting anything serious just some
information that should only be available to certain users. Any suggestions.
OS: Gentoo Linux 2.4
Apache: 2.0.50
Patrick O'Neal
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Two level access using Basic Authentication
Posted by Joshua Slive <js...@gmail.com>.
On Thu, 26 Aug 2004 10:05:09 -0400, Mark McCulligh
<mm...@visualtech.ca> wrote:
> <Directory /private>
It is highly unlikely that you have a folder named "private" off the
root of your filesystem. More likely, you want to have <Directory
/usr/local/apache2/htdocs/private> or something like that.
Joshua.
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
[users@httpd] Two level access using Basic Authentication
Posted by Mark McCulligh <mm...@visualtech.ca>.
Hi group,
I am trying to setup a two level security access using Basic Authentication.
I have a site that to gain access you must have a username and password.
Also I need to have a folder inside of the website that only certain users
can access. I have tried to create two groups and only let one group have
access to the private folder.
Here is my Auth code:
<Directory />
Authtype Basic
AuthName "Site Login"
AuthUserFile /???/password-file
AuthGroupFile /???/group-file
require group general admin //Both groups General and Admin have access to
root website
</Directory>
<Directory /private>
Authtype Basic
AuthName "Site Login"
AuthUserFile /???/password-file
AuthGroupFile /???/group-file
require group admin //Only group Admin has access to the private folder
</Directory>
This does not work both groups have access to the "private" folder. Can
someone tell me what I am doing wrong or tell me how I should be setting
this up.
Thanks,
Mark.
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] How to run php with virtual host based uid/gid on apache2 ?
Posted by Robert Andersson <ro...@profundis.nu>.
Stephan von Krawczynski wrote:
> Consider having a setup with around 2000 virtual hosts (with low average
> traffic) on linux. Using suexec to provide uid/gid for CGI scripts works
very
> well. Only real security issue is php as it runs with apache default
uid/gid.
> How can one change that?
Your best bet is to run PHP as CGI (through SuExec, of course).
There are also some "safe options" in PHP that limits its permissions (what
can be executed, files that can be written etc), but I'm not very familiar
with securing PHP that way. You could probably read something about this in
PHP's docs.
You cannot get the module version of PHP to serve requests under different
uid/gid without using the perchild MPM; which sadly isn't an option anyway.
Regards,
Robert Andersson
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] How to run php with virtual host based uid/gid on apache2 ?
Posted by Tim Burden <ti...@burden.ca>.
Just run PHP as CGI.
----- Original Message -----
From: "Stephan von Krawczynski" <sk...@ithnet.com>
To: <us...@httpd.apache.org>
Sent: Thursday, August 26, 2004 9:32 AM
Subject: [users@httpd] How to run php with virtual host based uid/gid on
apache2 ?
> Hello all,
>
> I tried to find an answer for this question for quite some time, but it
> seems
> no real solutions are present at this time.
> Consider having a setup with around 2000 virtual hosts (with low average
> traffic) on linux. Using suexec to provide uid/gid for CGI scripts works
> very
> well. Only real security issue is php as it runs with apache default
> uid/gid.
> How can one change that?
> Using MPM perchild is not really an option, as it runs at least one client
> per
> existing vhost (if I got that right) which is not really efficient for
> virtual
> hosts that have possibly one or two requests a day, and considering the
> number.
> I really would like to have some possibility to run php scripts with a
> virtual-host based uid/gid just like suexec. Is that possible at all?
>
> Regards,
> Stephan
>
>
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org