我想为我的虚拟主机设置一个不同的upload_max_filesize
。我在每个虚拟主机中都有一些web应用程序,所以在php.ini中全局更改值不是一个选项,因为我希望每个虚拟主机都有自己的值。
所以我尝试了以下方法:
<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/
换句话说,我正在尝试使用php_value upload_max_filesize 5M
在virtualhost.conf中设置值。我读到我想为AllowOverride
设置一个特定的值,我也试图在这里设置它,但这段代码不起作用。
我想在每个虚拟主机部分下保留这些设置,我不喜欢使用.htaccess文件。
我会把PHP设置放在Directory
指令中。您也应该将其作为Apache模块运行。
请确保安装了mod_php,并且在Apache配置中未对此进行注释。
LoadModule php5_module modules/libphp5.so
那么你应该能够使用这样的东西。
<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/
请确保在配置更改后重新加载/重新启动Apache。还注意到我将AllowOverride
设置为None
。你说你不想使用.htaccess,所以你需要禁用使用.htacccess文件。如果将其设置为All,Apache每次收到请求时都会扫描Web服务器以查找.htaccess文件。所以,即使你没有使用任何,它仍然在寻找它们。因此,为了消除对性能的小影响,请关闭使用None
完成的htaccess文件。