TechBuzzPro

Increase OwnCloud Max Upload Size: Step-by-Step

· 5 min read · Apps & Browsers

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

If you're getting "413 Request Entity Too Large" or "File exceeds upload_max_filesize" when uploading files to your OwnCloud server, the default PHP limits are likely too small. This guide walks you through raising the maximum upload size in OwnCloud by adjusting PHP settings, web server configuration, and OwnCloud's own config file. You'll need SSH or file manager access to your server, and you should know your web server type (Apache or Nginx).

What You'll Need

  • SSH access to the server running OwnCloud (or a file manager in your hosting control panel).
  • Root or sudo privileges to edit PHP and web server configuration files.
  • Knowledge of whether your web server is Apache or Nginx (check with ps aux | grep -E 'apache|nginx').
  • A text editor (nano, vim, or a graphical editor).

Step-by-Step

  1. Find the PHP configuration file. Run php --ini to see the loaded configuration file path (e.g., /etc/php/8.1/apache2/php.ini for Apache or /etc/php/8.1/fpm/php.ini for Nginx). Open it with a text editor.
  2. Edit the three key PHP directives. In the php.ini file, locate and increase these values (or add them if missing):
    • upload_max_filesize = 2G (sets the max file size for uploads)
    • post_max_size = 2G (must be equal to or larger than upload_max_filesize)
    • memory_limit = 512M (recommended at least 128M, but higher helps with large files)
    Save the file.
  3. Adjust the request timeout (optional but recommended). For very large files, increase max_execution_time = 3600 and max_input_time = 3600 in the same php.ini to prevent timeouts.
  4. Restart PHP. For Apache with mod_php, run sudo systemctl restart apache2 (or httpd). For PHP-FPM, run sudo systemctl restart php8.1-fpm (adjust the version).
  5. Configure Apache (if using Apache). If you're on Apache, you may need to adjust the LimitRequestBody directive. In your virtual host or .htaccess file, add or modify: LimitRequestBody 0 (0 means unlimited). Then restart Apache again.
  6. Configure Nginx (if using Nginx). In your Nginx server block, find the client_max_body_size directive. Set it to 2G (or your desired size). If it's not present, add it inside the server or location block. Then run sudo nginx -t to test the config and sudo systemctl reload nginx.
  7. Update OwnCloud's config.php. Open OwnCloud's config file (usually at /var/www/owncloud/config/config.php) and add these lines (if not already present):
      'max_chunk_size' => 104857600,
      'upload_max_filesize' => '2G',
        
    The max_chunk_size is in bytes (100 MB is a good default). Save the file.
  8. Clear OwnCloud's cache. Run sudo -u www-data php occ maintenance:repair from the OwnCloud root directory (or use the admin panel's "Clear cache" button).
  9. Verify the change. Log in to OwnCloud as an admin, go to Settings → General, and check the "Upload max size" value. It should reflect your new limit.

Common Mistakes

  • Setting post_max_size smaller than upload_max_filesize. This causes uploads to fail because POST data includes the file plus other form fields. Always set post_max_size >= upload_max_filesize.
  • Editing the wrong php.ini. Many servers have multiple PHP versions or separate CLI and web configs. Use php --ini to confirm you're editing the one used by the web server.
  • Forgetting to restart PHP or the web server. Changes to php.ini require a restart to take effect. Nginx requires a reload, Apache requires a restart.
  • Not updating Nginx's client_max_body_size. If you only change PHP, Nginx will still block large uploads with a 413 error.
  • Using a value over 2GB with 32-bit PHP. On 32-bit systems, PHP cannot handle file sizes above 2GB. Use 64-bit PHP for larger limits.

Tips

  • Start with a moderate value like 1G and test with a large file before going higher.
  • If you're using a reverse proxy (like HAProxy or Cloudflare), ensure it also allows large request bodies.
  • For very large files, consider enabling OwnCloud's chunked upload feature (it's on by default in recent versions) to avoid timeouts.
  • Monitor server memory: large uploads can consume significant RAM, so ensure your server has enough.
  • Use the occ command-line tool to check current settings: sudo -u www-data php occ config:list system.

Troubleshooting

  • Still getting 413 after changes? Check if a reverse proxy or load balancer is in front of your server. Adjust its request size limit (e.g., in HAProxy, set tune.maxrewrite or use a larger buffer). Also, ensure you've restarted all services.
  • Uploads fail with "Internal Server Error"? Check the PHP error log (/var/log/php_errors.log or journalctl -u php8.1-fpm). Common causes are memory_limit too low or missing write permissions on the temp upload directory.
  • OwnCloud shows "Upload max size" as 0? This often means the PHP config isn't being read correctly. Verify the php.ini path with phpinfo() and confirm you edited the right file.
  • Changes revert after restart? Some hosting panels (like cPanel) override PHP settings. Use the panel's PHP configuration interface or add a .user.ini file in the OwnCloud directory with the same directives.
  • Large files upload but fail during processing? Increase max_execution_time and check the OwnCloud log (data/owncloud.log) for specific errors. Also, ensure the disk has enough free space.

Frequently Asked Questions

What is the default upload limit in OwnCloud?

The default is usually 512MB, but it depends on your PHP settings. Most servers default to 2MB-128MB until changed.

Can I set the upload limit to unlimited?

Yes, but it's not recommended. Set upload_max_filesize = 0 and post_max_size = 0 in PHP, and client_max_body_size 0 in Nginx. However, this can lead to server resource exhaustion.

Why do I need to change both PHP and web server settings?

PHP handles the file upload processing, while the web server (Apache/Nginx) also has its own request size limits. Both must allow the file size for the upload to succeed.

How do I check the current upload limit?

Log in as admin in OwnCloud, go to Settings → General, and look for "Upload max size". You can also run php -r "echo ini_get('upload_max_filesize');" on the server.

Does the upload size affect file sharing links?

Yes, the same limit applies to files uploaded via public share links. The limit is enforced at the server level.

What if I'm using Docker for OwnCloud?

You need to set environment variables like PHP_UPLOAD_MAX_FILESIZE=2G and PHP_POST_MAX_SIZE=2G in your docker-compose file, and rebuild the container.