Increase PHP File Upload Limit

If you have installed a LAMP server either on your Linux desktop or server, you are bound to run into this problem. The default PHP installation placed a 2MB limit on file uploads. I ran into this problem when I tried to import a XML file that was bigger than 2MB into a WordPress install. So, to increase the upload limit, I edited the PHP configuration file called PHP.INI.

In Ubuntu, the default location for PHP.INI is in the /etc/php5/apache2 directory. So, let’s open up the Terminal and edit the PHP.INI file:

$ sudo vi /etc/php5/apache2/php.ini

Look for this entry in the file.

upload_max_filesize = 2M

Increase the limit to 10MB or to any value you prefer.

upload_max_filesize = 10M

Save file and exit.

Next, you will need to restart the Apache server for your changes to take effect. From the Terminal type this command to restart your Apache web server:

$ sudo /etc/init.d/apache2 restart

That’s it. Have fun uploading large files!