I'd like to set a distinct upload_max_filesize
for my virtualhosts. I have some web applications in each virtualhost, so changing the value globally in php.ini is not an option, as I'd like every virtualhost to have it's own value.
So I've tried the following:
<VirtualHost *:80>
ServerName www.test.com
ServerAlias test.com
DocumentRoot /var/www/html/test/
ErrorLog /var/log/httpd/test/error.log
CustomLog /var/log/httpd/test/requests.log combined
<Directory /var/www/html/test/>
AllowOverride All
</Directory>
php_value upload_max_filesize 5M
</VirtualHost>
Alias /test /var/www/html/test/
In other words, I'm trying to set the value within the virtualhost .conf with php_value upload_max_filesize 5M
. I read I'd to set an specific value for AllowOverride
and I'm trying to set it here too, but this code doesn't work.
I'd like to keep this settings under each virtualhost section, I won't prefer using an .htaccess file.
I would put the PHP settings in the Directory
Directive. You should be running this as an Apache module too.
Make sure you have mod_php installed and this is uncommented in the Apache config.
LoadModule php5_module modules/libphp5.so
Then you should be able to use something like this.
<VirtualHost *:80>
ServerName www.test.com
ServerAlias test.com
DocumentRoot /var/www/html/test/
ErrorLog /var/log/httpd/test/error.log
CustomLog /var/log/httpd/test/requests.log combined
<Directory /var/www/html/test/>
AllowOverride None
<IfModule mod_php5.c>
php_value upload_max_filesize 5M
</IfModule>
</Directory>
</VirtualHost>
Alias /test /var/www/html/test/
Make sure to reload/restart Apache after config changes. Also noticed I set AllowOverride
to None
. You said you do not want to use .htaccess so you need to disable using .htaccess files. If you set it to All, Apache scans the webserver for .htaccess files everytime it gets a request. So even if you aren't using any, it's still looking for them. So to eliminate the small performance hit, turn off htaccess files which is done with None
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With