Skip to content
Alfa Intelli
  • Home
  • About
  • Services
  • Knowledge Base
  • Tools
  • Contact Us
  • Alfa Intelli Tech

Increase Upload File Size Limit with Ubuntu/PHP

28 February 2023 · Email, Linux, Php, Ubuntu

← Knowledge Base

Increase Upload File Size Limit with Ubuntu/PHP

To increase the upload size limit, edit the PHP configuration file.

If you using php7.4 then replace 8.1 to 7.4 in the below commands

sudo nano /etc/php/8.1/fpm/php.ini

Find the following line.

upload_max_filesize = 2M

Change the value like below. Note that this value should not be larger than the attachment size limit set by Postfix SMTP server.

upload_max_filesize = 50M

Then find the following line.

post_max_size = 8M

Change the maximum size of POST data that PHP will accept.

post_max_size = 50M

Save and close the file. Alternatively, you can run the following two commands to change the value without manually opening the file.

sudo sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 50M/g' /etc/php/8.1/fpm/php.ini

sudo sed -i 's/post_max_size = 8M/post_max_size = 50M/g' /etc/php/8.1/fpm/php.ini

Then restart PHP-FPM.

sudo systemctl restart php8.1-fpm

Nginx also sets a limit of upload file size. The default maximum upload file size limit set by Nginx is 1MB. If you use Nginx, edit the Nginx configuration file.

sudo nano /etc/nginx/conf.d/mail.example.com.conf

Add the following line in the SSL virtual host.

client_max_body_size 50M;

Save and close the file. Then reload Nginx for the changes to take effect.

sudo systemctl reload nginx

Tags: PHP, ubuntu

Comments (1)

Baldeep15 March 2023

worked great, was really helpful.

← Install Roundcube Webmail with NginxInstall WordPress on Ubuntu 20.04 with Nginx, MariaDB, PHP7.4 (LEMP) →

Related guides

How to Resolve the DKIM Test Error: Unexpected Reply Class/Type (-1/-1)

23 January 2025Read the guide

Install SpamAssassin with Content Filter

5 March 2023Read the guide

Block Email Spam with Postfix

2 March 2023Read the guide

Need help with your IT?

Let's talk

Contact Us

India

74-81 District Shopping Centre
Sri Ganganagar
Rajasthan - 335001

Australia

241-243 Princes Highway
Corrimal
NSW - 2518

Trading Hours

  • Monday - Friday --- 10 AM to 6 PM (IST)
  • Saturday -- Close
  • Sunday -- Close

© 2026 Alfaintelli Group