I cannot save php.ini in ubuntu 12.04

I want to change the upload_max_filesize = 2M to 50M, then I started edit on php.ini, but when try to save it, it displays error message below

Could not create a backup file while saving /etc/php5/apache2/php.ini

gedit could not back up the old copy of the file before saving the new one. You can ignore this warning and save the file anyway, but if an error occurs while saving, you could lose the old copy of the file. Save anyway?

cannot save php.ini


You are opening that file in a folder owned by root! Hence you need root access to that file. Type this code in the terminal:

sudo -H gedit /etc/php5/apache2/php.ini

When the file opens edit the file and you can save it normally by pressing Ctrl+S


You don't have permission when your text editor creates a backup file.

You can either

  1. Run gedit using administrative permission.

    sudo -H gedit /etc/php5/apache2/php.ini
    

    In this part gedit will create a backup file with root permission. A new file will be created with root as owner.

or

  1. You can disable the gedit feature thats create backup copy before saving.

    Go to Edit > Preferences > Editor

    Uncheck Create a backup copy of files before saving