editing php.ini using ssh

Suspended
Joined
30 Jan 2005
Posts
467
ive been told i need to access my php.ini file via ssh to edit a setting.

i can log into my ssh and i get a basic white page with the following text

root@server [~]#

im guessing i need to type a command in to access my php.ini file. could anyone tell me how. thanks :)
 
You'll need to find out where it is then edit it with a command-line editor.

Upload and view a PHP file with the following content:

Code:
<?php

phpinfo();

?>

And look for the line in the first section that says:

Code:
Configuration File (php.ini) Path

The bit next to it is your php.ini's location. For example, my local one says:

Code:
Configuration File (php.ini) Path 	C:\apache\xampp\apache\bin\php.ini

Now you'll need to fire up an editor to edit that file. Nano is probably the easiest to use, which would involve running:

Code:
nano /etc/php.ini

(Presuming /etc/php.ini is the location phpinfo() told you.)

However, you might not have nano installed. You'll almost certainly have vim installed, but it's a little more difficult to use.

However, if you're just making a quick edit:

Run:

Code:
vim /etc/php.ini

Scroll to where you want to edit using the arrow keys. Hit "i" to enter "insert" mode. Make your changes. Hit "Escape". Type "ZZ" to save and exit (it's case sensitive, so hold shift and hit z z).

Phew!

By the way, it'd probably be worth learning at least basic vim skills, since it's pretty much the one editor you can always rely on being installed when you SSH into a server :)
 
Vi... *shudder*. Feels like you need the skills of a contortionist to execute some commands :D. echo export VISUAL="nano" >> ~/.bashrc :cool:.
 
Back
Top Bottom