How to edit the php.ini file on a Unix based server using SSH.
It’s important to alter the php.ini file on any new server as most are set up for very generic use and can sometimes pose a security threat to your site. A classic but simple example of this is the “Show Errors” setting; having this active on a live site can give people serious insight into how your site works and, by forcing errors, can give away information you don’t want them to have.
This article does not go through all the security implications of the php.ini file but it does, however, cover how to make changes via the Unix shell – more specifically the Vi editor.
- Connect to your server via SSH.
- Locate your php.ini file (contact your hosts if you can’t find this).
- Navigate to the same directory as your php.ini file. To open the file for editing, type the following:
This opens the PHP file in the Vi editor. Using the Vi editor can be pretty tricky so I’m just going to cover the basics when it comes to editing and saving the file. If you require a full step-by-step breakdown, please click here. Okay, so we have the file open and at the moment you are in “command” mode (this means you’re not actually editing anything)…
- Use the arrow keys to navigate around the document, in the current “command” mode you can freely move around the document without actually editing any of the content. We want to navigate down the document till we find a setting saying something like:
; Maximum allowed size for uploaded files.
upload_max_filesize = 32M
Once you’ve located the setting, simply set the value to what you need.
- Save the file and restart your vps.
That’s it, job done!