Page 1 of 1

Environment variables in httpd.conf - PHP as apache module?

Posted: Wed Nov 05, 2008 7:55 am
by mothmenace
Hello,

I have a problem with getting an ini config option set via http.conf in one directory (rather than whole server). Here's the 'stack trace' of my problem :)

Using Zend Framework on Media Temple DV hosting
Need to use APC to speed things up
want to enable APC in one dir not the whole hosting
I'm setting APC.enabled to 0 in php.ini, want to set it to 1 in the http.conf
It's not working! :(

phpinfo() shows the correct values under master/local, so does ini_get() in a script. But these values are not having any effect on the environment it seems - APC won't load unless I set in php.ini, open_basedir also problematic

Am I right in understanding that to set ini configuration values in http.conf or htaccess, you MUST run PHP as an Apache module? It is currently set as Fast-CGI afaik, this is hosting default setup.

If so, my next question is going to be how to set up PHP as Apache module ... 8O

Thanks for your time

Re: Environment variables in httpd.conf - PHP as apache module?

Posted: Wed Nov 05, 2008 11:43 pm
by infolock
K, I'm going to carefully try to answer this as I've dealt with APC only once in my life here, but never to the extreme in which you are trying to go about it.

First, yes you have to have PHP installed as a module in apache to change these settings. Go here for basic installation instructions for installing PHP as a module for apache. (look for the AddType and LoadModule sections).

Secondly, you can change the properties of PHP via ifModule. Example

Code: Select all

 
<IfModule mod_php5.c>
  php_value error_reporting "E_ALL"
</IfModule>
 
As for enabling on a single directory, that's way over my head for apache unfortunately :(

Hope this helps you some how..

Re: Environment variables in httpd.conf - PHP as apache module?

Posted: Thu Nov 06, 2008 2:33 pm
by mothmenace
Thanks a lot for helping me out!

I didn't have to reinstall php as a module thankfully because it was already set up that way. It seems the easiest way to toggle APC off/on in different dirs is to set apc.cache_by_default to Off in php.ini, then On in the relevant dir (or vice versa). They use Plesk on my server, so this is what my vhost.conf looked like (which effects the whole subdomain), probably the same for .htaccess in a dir too:

<Directory "/var/www/vhosts/domain/httpdocs">
AllowOverride All
Options +Indexes
php_admin_flag apc.stat Off
php_admin_flag apc.cache_by_default On
</Directory>

I wouldn't normally mess with this stuff but it was necessary to speed up the Zend Framework.
Many thanks again for your time

Re: Environment variables in httpd.conf - PHP as apache module?

Posted: Thu Nov 06, 2008 9:40 pm
by infolock
Ahhh, very nice man, I'm gonna have to bookmark this one. Thanks for sharing and glad i could help!