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

Ubuntu自建LAMP服务器上传限制无法突破2MB,急求技术支持

Fixing Upload Limit Stuck at 2MB on Ubuntu LAMP Stack

Hey there, I feel your pain—trying to upload a premium theme but hitting that stubborn 2MB limit even after tweaking settings is super frustrating. Let’s walk through a thorough troubleshooting process tailored to Ubuntu’s LAMP setup:

1. Locate & Edit the Correct php.ini Files

Ubuntu often has separate php.ini files for CLI and web server contexts, so you might’ve edited the wrong one without realizing it.

  • First, find the php.ini used by Apache:
    php -i | grep "Loaded Configuration File"
    
    This will output a path like /etc/php/8.1/apache2/php.ini (adjust the version number to match your PHP install).
  • Open this file with a text editor (e.g., nano):
    sudo nano /etc/php/8.1/apache2/php.ini
    
  • Update these critical parameters (set values larger than your theme’s file size—64M is a safe default for most premium themes):
    upload_max_filesize = 64M
    post_max_size = 64M  # Must be equal to or larger than upload_max_filesize
    memory_limit = 128M
    max_execution_time = 300  # Gives enough time for large file uploads
    
  • Save the file (Ctrl+O, Enter, then Ctrl+X in nano) and restart Apache to apply changes:
    sudo systemctl restart apache2
    

2. Check for .htaccess Overrides

If your website uses an .htaccess file (common with WordPress, Drupal, etc.), it might be overriding your php.ini settings.

  • Navigate to your site’s root directory and open .htaccess:
    sudo nano /var/www/html/.htaccess
    
  • Look for lines like these—if they exist, update the values:
    php_value upload_max_filesize 64M
    php_value post_max_size 64M
    php_value memory_limit 128M
    php_value max_execution_time 300
    
  • If the lines aren’t present, add them to enforce your desired limits. Save and close the file.

3. Verify PHP-FPM Settings (If Using FPM)

Many modern LAMP setups use PHP-FPM instead of mod_php. If that’s your case:

  • Find the FPM php.ini file (path example: /etc/php/8.1/fpm/php.ini) and repeat the parameter updates from step 1.
  • Restart PHP-FPM and Apache:
    sudo systemctl restart php8.1-fpm
    sudo systemctl restart apache2
    

4. Confirm Changes Are Active

Create a quick test file to verify your settings took effect:

  • Make a phpinfo.php file in your site’s root:
    sudo nano /var/www/html/phpinfo.php
    
  • Add this content:
    <?php phpinfo(); ?>
    
  • Save the file, then visit http://your-server-ip/phpinfo.php in a browser.
  • Search for upload_max_filesize and post_max_size—they should show your updated values. If not, double-check that you edited the correct php.ini file and restarted the right services.

5. Check CMS-Specific Limits

If you’re using a CMS like WordPress, double-check its internal settings:

  • For WordPress: Go to Settings > Media and ensure the "Max upload file size" matches your PHP settings. Some themes/plugins might override this, so you may need to adjust it here too.

If you still run into issues, share details like your PHP version, Apache version, and which CMS you’re using—that’ll help narrow down the problem further.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.19 03:21:53