Access to Edit php.ini file?

November 13, 2007 / Web Hosting

By following these steps you can edit a php.ini file:

  1. First find the location of php.ini file
  2. Place this script on your server.
  3. Run this script in your Web browser by going to http://anyofyour.url.here/phpinfo.php in your Web browser (on your own computer, this may be like http://localhost/phpinfo.php or http://localhost/~username/phpinfo.php).
  4. In the result page, look for the line which says “Configuration File (php.ini) Path”. It should be about 6 rows down in the table.
  5. Note the location of your php.ini file. It is the active file PHP is using. Your server may have multiple php.ini files on it but this is the one that counts.
  6. If you don’t have a php.ini file on your server (if the value is blank in the phpinfo.php script or if you go to the directory it lists and there’s no php.ini file there), create it one by one :
    1. Download the complete source code from http://www.php.net/downloads.php.
    2. Extract the source (unzip or whatever)j so that you now have a folder of files.
    3. Find the php.ini-dist file, located in the main folder.
    4. Rename this file as php.ini and move it to the proper directory.
  7. Open the php.ini file in a text editor (do not use Notepad, Word, TextEdit, or any other text editor which will not properly display line or will not let you save a plain text file).
  8. Make the changes you want, keeping in mind the following:
    1. Comments are marked using a semi-colon(;). Anything after the semi-colon is ignored.
    2. Instructions on what most of the settings mean are included in the file.
    3. The top of the page lists general information with examples. Do not change these values. Change the settings where they appear later in the file.
    4. Note for safety purposes, do not change any default settings, just comment them out (by preceding the line with a semi-colon), then add the new, modified line afterwards.
    5. Add a comment (using the semi-colon) to mark what changes you made and when. For example:
      ; register_globals = Off
      register_globals = On ; Added by LEU 1/9/2007
  9. Save the file.
  10. Restart the Web server (Apache, IIS, etc.). You do not need to restart your whole computer.
  11. Rerun the phpinfo.php script to make sure the changes took effect.