I have multiple sites running on Apache2 and PHP on Ubuntu Server. I know PHP has a php.ini file that lets you set values for upload_max_filesize
, max_file_uploads
, upload_tmp_dir
etc. But that applies one value to all sites.
How can set directives for each site? For Eg: I'd like to set upload_max_filesize
to 50M for sitea.com
and upload_max_filesize
to 5M for siteb.com
.
Similarly, I'd like to set unique a session.name
for each sites. How can this be done? I read there's something called PHP_INI_USER
, PHP_INI_PERDIR
, PHP_INI_SYSTEM
, PHP_INI_ALL
, so how can I do this?
You can use .htaccess
files per site (or even per-folder) to set PHP configuration values - at least for most settings: if you look in the configuration directives documentation, for every setting that is marked as either PHP_INI_PERDIR
or PHP_INI_ALL
you can set these in a .htaccess
file using the php_value
or php_flag
commands as documented in PHP's "How to change configuration settings" document.
For example to set upload_max_filesize
in a website, create a .htaccess
file at the document root of that website and put in it the text:
php_value upload_max_filesize 24M
Unfortunately, max_file_uploads
and upload_tmp_dir
are settings marked as PHP_INI_SYSTEM
and you cannot change them in a .htaccess
file...