?
Solved

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

Posted on 2005-03-01
14
Medium Priority
?
344 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

 
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

WordPress Tutorial 3: Plugins, Themes, and Widgets

The three most common changes you will make to your website involve the look (themes), the functionality (plugins), and modular elements (widgets).

In this article we will briefly define each again, and give you directions on how to install them.

Question has a verified solution.

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

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

752 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