Comments on How to Specify a Custom php.ini for a Website (Apache2 with mod_php)
This short article explains how to specify a custom php.ini for a website running on Apache2 with mod_php. That way, each website can have it's own php.ini instead of using the server's default one.
14 Comment(s)
Comments
i use .htaccess to change certain php_value....
any comment about my method?
you can't change all values from htaccess , but it a simple way to change simple things , and i think using the php.ini itself decrease the load on apache
Hi,
This information is wrong. With Apache 2.2.10 + you can 't have INI for each virtual site. If specifiy in more than conf file you will get error that you can define PHPINIDIR only once and subsequent definitions will be ignored.
majo
<VirtualHost *:8000>
php_value include_path ".:/my/other/include/path"
....
</VirtualHost>
Perfect! That worked for me.
I managed to configure both PHPINIDir and include_path in my virtualhost.conf
Thank you
You can use .htaccess to change certain php_values The syntax cab be: php_value setting_name setting_value php_value magic_quotes_gpc On
My experience matches majo's. With my apache 2.2x, I could not set separate php.ini files for each site, even using httpd.conf.
However, it may be possible to set specific php variables on a per-site basis if you have access to httpd.conf.
I was able to set some php_value variables in .htaccess, but php_admin_value variables, such as "sendmail_path" must be set in httpd.conf. My only goal was to use separate msmtp accounts to send through Google Apps from different sites.
I did this by putting the following inside the root directory <Directory> tags for each site:
php_admin_value sendmail_path "/usr/bin/msmtp -C /path/to/msmtprc -t"
For example:
<Directory "/var/www/site1">
php_admin_value sendmail_path "/usr/bin/msmtp -C /path/to/site1msmtprc -t"
</Directory>
<Directory "/var/www/site2">
php_admin_value sendmail_path "/usr/bin/msmtp -C /path/to/site2msmtprc -t"
</Directory>
In my case, I have separate conf files for each site, and I placed these strings inside each conf file between the <VirtualHost> tags. I am not sure if these commands would work outside of a virtual hosting situation, but it may be worth a try.
I know this is a bit off-topic, but I found this site looking for the information that I have written here; hopefully this may help someone else.
In Apache 2.2 there is a directive called SetEnv that is available at the VIrtualHost level and seems to work like so:
SetEnv PHPRC /path/to/ini
Is this the reason that I can't seem to change my php settings?
It's pointing to the file but not really doing anything with it. Would explain a lot why I can't seem to fix the HTTP upload error in the back end of magento...
Ok, but I don't have a command shell access on server and I don't have the possibility to restart the server. All I have is the ftp access to public_html folder. Is it any way to increase some php value without to ask every time to the host company?
Very helpful tutorial, thank you!
PHPINIDir not working
This directive works fine, but you have to be aware that you can set it only for one website on a server.
Excellent article. It worked like a charm.
Regards.