Changing the php file upload limit in Ubuntu Linux

If you have your own Ubuntu server running you may encounter the maximal file size upload limit in php scripts which is set to 2Mb as default. In order to change that we first have a look what the size actually is. In /var/www (standard www directory) create a file called info.php with the following content:

<?php
// Show all information, defaults to INFO_ALL
phpinfo();
?>

Then browse to this file via http://localhost/info.php (replace localhost with the servername if necessary) and look for the line

upload_max_filesize 2M 2M

which will show you the actual maximum file size. In order to change that open a ssh connection to your server and edit the file /etc/php5/apache2/php.ini with

sudo nano /etc/php5/apache2/php.ini

search for “upload_max_filesize” with Ctrl-W and change “2M” to “20M”. Save the file with Ctrl-O and exit with Ctrl-X. Restart the apache server with

sudo /etc/init.d/apache2 restart

and visit again http://localhost/info.php to check if the maximum file size was changed.

8 thoughts on “Changing the php file upload limit in Ubuntu Linux

  1. While is may be common sense to some, for those people new to messing around with servers, don’t forget to restart Apache for the changes to take effect.

    You can use this line to do so:

    sudo /etc/init.d/apache2 restart
    
  2. Thanks, helped me a bunch 🙂

    I am migrating from using Fedora to Ubuntu and the PHP and apache files are in a different place.

    You Could also add the other commonly changed one max_post_size.

    I was atempting to import my database using phpmyamdin so had to change that 🙂

    Bob

  3. Hi, I’ve followed your very clear instructions but the php.ini file is not getting updated. I’ve checked the location from the info list and its the same. What else can I do? Is there another file lurking somewhere?
    I’m using Ubuntu 11.04 and Xampp.

Leave a Reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.