setting up apache "virtual servers" with custom php.ini's

Ok, my current host (www.powweb.com) allows each user to eith use the default php settings, OR create their own php.ini file, and put it in their htdocs dir. I'm trying to do something similar with a server I have that will host a few different test sites. How would I go about doing this?
aaroncampbellAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ahoffmannCommented:
is this a duplicate question to http:/Q_21333510.html ?

if you use php as module in apache (mod_php) then you can only have one php.ini (searched at the default place), 'hence there is no way to have different ones for each virtual host.
You need to use PHP as CGI, then each CGI can read its own php.ini.
Or you need to use one serverinstance for each virtual host (which requires a unique IP for each)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
aaroncampbellAuthor Commented:
yes it's a dupe.  I wasn't sure which section to place it in (php install, or apache), and I had enough points to put it in both...so I did.  The problem is, I'm running php as a module, and would like to be able to still do this.  Does anyone know of a way to do this with php as a module?
0
AndyWHVCommented:
i would recommend to customize the information for the virtualhosts.
in most cases its enough to change only some of them.

you can do this with entering a line like

php_admin_value open_basedir /srv/www/htdocs/myownweb
php_admin_value upload_tmp_dir /var/www/my_upload/temp
php_admin_value session.save_path /var/www/mysessions/temp/
php_admin_value safe_mode on

you could write a script for the necessary entries.
thats the way i do it.

the syntax is:
php_admin_value config_param_name config_param_value

greetz andy
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

AndyWHVCommented:
here is a more detailed description for php_admin_values:
http://de2.php.net/configuration.changes

if you want to use php the cgi way described by ahoffmann i could recommend suphp
http://www.suphp.org
(like suexec - but expecially for php)
0
ahoffmannCommented:
php_* settings in httpd.conf do not work per virtual host 'cause php is a module loaded for all virtual hosts
0
AndyWHVCommented:
i have an open_basedir and include path and so on for each virtual host.
i did it this way and it works.

(apache 1.3 and mod_php4)

open_basedir is PHP_INI_SYSTEM but is specified in each virtual host.

here is a php_info example from one virtualhost:

                       local                                 master
open_basedir      /home/www/dps13112      /home/www/:/usr/local/lib/php/

0
ahoffmannCommented:
AndyWHV, does this mean that you have used something like:
  php_value open_base_dir  /home/www/dps13112
and works with different values for each virtual host?
that's new to me ...
0
AndyWHVCommented:
yeah, but i used it with

php_admin_value that it can't be overriden
(well, i think PHP_INI_SYSTEM can't never be overriden by the user, cause its not changeable in htaccess context)

i did it like this:

php_admin_value open_basedir /home/www/dps13112

in virtual host context.

i needed it because we had several hacking attempts on some virtual hosts with bad programmed gallerys
and when you're not lucky all virtualhosts will be affected of defacing or something else.

so i gave every virtual hosts an individual open basedir and upload dir
when there's a hacking atttempt only the unsecure user is affected now.

0
ahoffmannCommented:
according PHP docs php_admin_value cannot be used in .htaccess and virtual hosts (as I said), wondering ...
0
AndyWHVCommented:
have a look here:

http://de.php.net/features.safe-mode

under open_basedir :

' In httpd.conf, open_basedir can be turned off (e.g. for some virtual hosts) the same way as any other configuration directive with "php_admin_value open_basedir none". '

i think they explained it a bit complicated on the other page about apache configuration.
in the manual there are a few user comments where they use it in virtual host context.

a better source is google or something similar.
0
ahoffmannCommented:
hmm, that's the useless (somehow) safe_mode ...
I doubt that this works with virtual hosts 'cause php_admin_value does not (sorry can't test)
0
AndyWHVCommented:
well.....
it definitely does, cause i have it running like this...
on multiple machines
0
ahoffmannCommented:
then it's a nice feature, should check it myself 'cause I was looking for since long .. Thanks.
0
AndyWHVCommented:
i found something on the button of the manual page from php.ini directives

http://de.php.net/manual/en/ini.php#ini.list

open_basedir ist PHP_INI_SYSTEM      
and on the bottom they say...

PHP_INI_SYSTEM      4      Entry can be set in php.ini or httpd.conf


0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.