Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2005-03-01
14
Medium Priority
?
347 Views
Last Modified: 2013-12-13
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?
0
Comment
Question by:aaroncampbell
  • 7
  • 6
14 Comments
 
LVL 51

Accepted Solution

by:
ahoffmann earned 2000 total points
ID: 13432719
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
 

Author Comment

by:aaroncampbell
ID: 13432937
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
 
LVL 3

Expert Comment

by:AndyWHV
ID: 13448891
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 3

Expert Comment

by:AndyWHV
ID: 13449043
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 13449317
php_* settings in httpd.conf do not work per virtual host 'cause php is a module loaded for all virtual hosts
0
 
LVL 3

Expert Comment

by:AndyWHV
ID: 13449928
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 13450501
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
 
LVL 3

Expert Comment

by:AndyWHV
ID: 13450713
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 13450834
according PHP docs php_admin_value cannot be used in .htaccess and virtual hosts (as I said), wondering ...
0
 
LVL 3

Expert Comment

by:AndyWHV
ID: 13451254
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 13451666
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
 
LVL 3

Expert Comment

by:AndyWHV
ID: 13451903
well.....
it definitely does, cause i have it running like this...
on multiple machines
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 13452589
then it's a nice feature, should check it myself 'cause I was looking for since long .. Thanks.
0
 
LVL 3

Expert Comment

by:AndyWHV
ID: 13462337
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

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question