Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > HOWTO-Related Questions

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 11th December 2006, 16:08
Sid Sid is offline
Junior Member
 
Join Date: Nov 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default VHosts + basedir + PHP4 and PHP5 at same time

Hi everybody,

i have php5 running as apache mod and php4 as cgi.
in my apache config i set an open_basedir for each vhost.
is it possible to set individual basdirs for php4-cgi too?

I want to forbid users to acccess files of other users. all user dirs have the same uid and guid (FTP setup is pureftpd with virtual hosting)
Reply With Quote
Sponsored Links
  #2  
Old 12th December 2006, 15:19
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,751 Times in 2,581 Posts
Default

Can you post your vhost configuration here?
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #3  
Old 12th December 2006, 23:04
Sid Sid is offline
Junior Member
 
Join Date: Nov 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In httpd.conf:
Code:
ScriptAlias /php4-cgi "/usr/lib/cgi-bin/php4"

AddHandler php-script .php4
Action php-script /php4-cgi
for .php4 files to be parsed with php4-cgi

a sample of a vhost config:
Code:
<VirtualHost *:80>
        ServerAdmin some@email.org
        ServerAlias domain www.domain
        ServerName domain

        DocumentRoot /home/www/domain/htdocs/
                                                                                
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /home/www/domain/htdocs/>
                Options -Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
                php_admin_value open_basedir /home/www/domain
        </Directory>

<Directory "/usr/lib/cgi-bin/php4">
php_admin_value open_basedir /home/www/domain
</Directory>

        ScriptAlias /cgi-bin/ /home/www/domain/cgi-bin/
        <Directory "/home/www/domain/cgi-bin">
                AllowOverride None
                Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog /home/www/domain/log/error.log
        LogLevel warn
        CustomLog /home/www/domain/log/access.log combined
        ServerSignature On
</VirtualHost>
The part <Directory "/usr/lib/cgi-bin/php4">
php_admin_value open_basedir /home/www/domain
</Directory> was just added for testing but has no effect on php4-cgi...
Reply With Quote
  #4  
Old 13th December 2006, 15:39
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,751 Times in 2,581 Posts
Default

I'm not quite sure if open_basedir, safe mode, etc. work for PHP-CGI because it was developed primarily for mod_php. For the CGI versions you can use suExec and suPHP.
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #5  
Old 13th December 2006, 20:43
Sid Sid is offline
Junior Member
 
Join Date: Nov 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

safe_mode is already working because it was defined in php.ini
I got an idea... maybe it will work with parameters to php4-cgi...
Reply With Quote
  #6  
Old 14th December 2006, 19:20
Sid Sid is offline
Junior Member
 
Join Date: Nov 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Now its working fine... the solution if someone is interested:

create a direktory to store a php4 startscript for each user like /var/www/php4

then create a bash script named domain or so in this directory containing
Code:
#!/bin/sh
unset SERVER_NAME
unset SERVER_SOFTWARE
unset GATEWAY_INTERFACE
unset REQUEST_METHOD 
/usr/lib/cgi-bin/php4 -d open_basedir=/home/www/domain '$*'
then edit the vhost apache config and add:
Code:
ScriptAlias /php4-cgi "/var/www/php4/domain"
AddHandler php-script .php4
Action php-script /php4-cgi
4 env variables are dropped but safemode with open_basedir is working
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
php5 and php4 at the same time Hans Installation/Configuration 15 22nd October 2008 14:02
PHP5 in apache PHP4 at cli. how do get get PHP5 at both ThE-LyNX Installation/Configuration 1 29th August 2006 00:49
suse 10.1 php5 to php4 Boon-Dog-Danny Installation/Configuration 2 6th August 2006 16:09
Running Apache2 With PHP5 And PHP4 At The Same Time hansmi HOWTO-Related Questions 3 28th June 2006 10:49
PHP4 and PHP5 for SUSE 9.3 Prof M.Behrens Installation/Configuration 3 2nd April 2006 23:20


All times are GMT +2. The time now is 13:05.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.