You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Amazon EC2 Ubuntu实例PHP文件上传大小限制无法修改求助

Troubleshooting PHP Upload Limits on Amazon EC2 Ubuntu Instance

Let's work through this step by step—since your CLI PHP config shows the correct values but Apache's PHP isn't picking them up, the issue is almost certainly that Apache is using a different configuration file or has overrides somewhere.

1. Confirm the exact php.ini file Apache is using

First, go to your phpinfo page and look for the Loaded Configuration File line. This tells you the exact php.ini file Apache's PHP module is loading.

Even if you edited /etc/php/7.0/apache2/php.ini, sometimes distros or custom setups can have Apache point to a different path. Make sure the values upload_max_filesize = 50M and post_max_size = 1000M are set correctly in this specific file.

2. Check for Apache virtual host overrides

Apache virtual hosts can override PHP settings directly in their config files. Navigate to your site's virtual host config (usually in /etc/apache2/sites-available/ with a .conf extension) and look for lines like:

php_value upload_max_filesize 2M
php_value post_max_size 8M

If you find these, update them to your desired values (50M and 1000M), save the file, and restart Apache.

3. Check .htaccess for overrides

If your web root (/var/www/html/) has an .htaccess file, it might also contain PHP value overrides. Open it and search for lines starting with php_value related to upload limits. If present, modify or remove them, then test again.

4. Verify you're restarting Apache correctly

Make sure you're using the right command to restart Apache on Ubuntu:

sudo systemctl restart apache2

After restarting, run sudo systemctl status apache2 to confirm there are no errors in the config that might be causing Apache to fail to reload the new settings.

5. Check Apache's own request size limit

Apache has a LimitRequestBody directive that can restrict the size of incoming requests, regardless of PHP settings. Search for this in your Apache configs:

grep -r "LimitRequestBody" /etc/apache2/

If you find a value set to something less than your desired max upload size (e.g., 2097152 for 2MB), update it to a higher value (like 1048576000 for 1000MB) or set it to 0 (unlimited). Don't forget to restart Apache after changing this.

6. Ignore .ebextensions (you're not using Elastic Beanstalk)

Since you're running a plain EC2 instance (not Elastic Beanstalk), the .ebextensions folder won't do anything—you can remove that if you added it, as it's irrelevant here.

Once you've gone through these steps, reload your phpinfo page to see if the settings updated. If they still don't, double-check the Loaded Configuration File path again to ensure you're editing the right file, and make sure there are no typos in the values (e.g., no missing M or extra spaces).

内容的提问来源于stack exchange,提问作者alyssaeliyah

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 10:01:58