Overriding php.ini Values For VirtualHost with .htaccess

Putting up a LAMP (Linux/Apache/Mysql/PHP) stack here at work and have a quick little one for you today: how to override the php.ini values in each virtualhost.

lampstack

First, you can load phpinfo() in a browser to find all sorts of settings and the location of the php.ini file

Create a file called phpinfo.php

 

Now load that into your browser to get all sorts of great info

phpinfo output

Now you could change your php settings in the system php.ini file, but that affects every website (a.k.a. virtualhost).

In most cases you can put php values directly into the .htaccess for each site (nay..each DIRECTORY) so users and accounts and sites can control their own


Sponsored Links





Sponsored Links



First, in the httpd.conf or apache conf file, change the default:

AllowOverride None

to

AllowOverride Options

(alternatively AllowOverride All)

Restart apache

apachectl restart

And now in .htaccess you can add something like:

php_value max_execution_time 120
php_value max_input_time = 120

And voila!! Custom php.ini values per directory!
virtualhost override php.ini values pic

Linux

Leave a Comment

Your email address will not be published. Required fields are marked *

Spam protection by WP Captcha-Free