How to change the maximum uploading size for PHP with Apache on Linux?

Posted on In Tutorial

How to change the maximum uploading size for PHP with Apache on Linux?

PHP has parameters to control the maximum uploading size. Here, we use Ubuntu 18.04 LTS default version as an example.

First, open the php.ini configuration file using your favorite editor

/etc/php/7.2/apache2/php.ini 

Then, find the following parts

; Maximum size of POST data that PHP will accept.
; Its value may be 0 to disable the limit. It is ignored if POST data reading
; is disabled through enable_post_data_reading.
; http://php.net/post-max-size
post_max_size = 20M
; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
upload_max_filesize = 20M

and change them to the size you prefer.

Last, restart apache2 to make the new parameters take effect.

$ sudo systemctl restart apache2