Permission denied to PHP.ini

January 5, 2016 3k views

Hi. I want to update the uploadmaxfilesize in php.ini document but apparently i don't have permission to edit this file. Is there anyone know how to get access to be able to modify this number?

2 Answers

System settings files, such as php.ini, typically require root level permissions to modify. Sometimes, settings files even require root to even read them, since they may contain login credentials for databases and such.

You'll need to elevate to root, usually using the sudo command to execute your editor, and that will require you to enter your password the first time you do it within a configured session lifetime.

Or you could su to root, but typically, droplets don't come configured with a root password, so password login to root won't even work.

  • Thank you. The problem here is i can't access my root as well. I don't know exactly what happened but every single time i try to access root, i get this message Permission denied, please try again. I reset password, i removed ssh-key but still have the same problem. Do you have an idea?

I take it you have created a new user on initial setup and granted admin privileges to the new user? somewhere in line with this guide

If you have try this...

Login with created user credentials:

ssh username@ip address`

Once logged in type this:

sudo bash

Enter your password, this should then show you in control as root user (root@yourdropletname:~#) Next enter this:

nano /etc/ssh/sshd_config

Search for a section where it says "PermitRootLogin" and if set to 'no' change to 'yes'

Press 'Cntl+X' to exit then 'Y' then 'ENTER' to save.


reload ssh

Now root (<---user) login through SFTP to change you php.ini file inside etc/php5/apache2/ to suit. Once this has been edited and saved go back to the nano /etc/ssh/sshd_config step and change back 'PermitRootLogin' to 'no' and remember to reload ssh again.

Finally use this command:

sudo service apache2 restart

Hopefully that should do it! Worked for me : )

by Justin Ellingwood
When you start a new server, there are a few steps that you should take every time to add some basic security and give you a solid foundation. In this guide, we'll walk you through the basic steps necessary to hit the ground running with Ubuntu 14.04.
Have another answer? Share your knowledge.