How To Increase PHP File Upload Limit on CentOS 7

How To Increase PHP File Upload Limit on CentOS 7 with one line of bash.

SSH into your server as root and execute the following command:

1
replace "upload_max_filesize = 2M" "upload_max_filesize = 20M" -- /etc/php.ini && service httpd restart

That will replace your 2mb upload limit with a 20mb upload limit and it will restart the web server so changes to php.ini are made:

Done.

P.S. you can verify your new maximum PHP file upload size is by executing:

1
grep upload_max_filesize /etc/php.ini

Sample output:

1
upload_max_filesize = 20M

Universal way to increase PHP Upload Limit:

SSH into your server as root. Use vi or nano to edit the php.ini file:

1
vi /etc/php.ini

Press / and type upload_max
(Pressing backslash (/) allows you to search a file while editing with Vi)

You should see:

1
upload_max_filesize = 2M

Press i and change that value to 20M
(Pressing “i” allows you to insert type in characters while editing with Vi)

1
upload_max_filesize = 20M

To exit Vi, press Esc and type

1
:x

and hit enter.

Now either

1
reboot

your server or restart httpd:

1
service httpd restart

Your PHP upload limit is now 20mb.