المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : How to use a custom php.ini file ?



bahattab
09-03-2010, 09:59 PM
How to use a custom php.ini file

If you use php then the odds are you may need to consider using a custom php.ini file at some point.

You can check your current php settings using the phpinfo() function. Make a .php file that has this one line:

<?php phpinfo() ?>


The execute it. That will tell you the default settings on your server, and it will tell you the location of the default php.ini file.

You may also want to make other changes to allow larger file uploads through php scripts, to set your own sessions directory for better security, to set a temp upload directory, or to change any number of other settings.

If you want to use a custom php.ini file, there are two things to remember:

1) Placement of the custom php.ini file is important. If you want to have the php.ini file work for just one directory (say for testing), then place it in that directory. If you want the custom php.ini file to work for the entire site, then add this line to your .htaccess file in your public_html directory:


SuPHP_ConfigPath /home/username/directory/



You can place this file anywhere you wish, even above the public_html directory so it is not web accessible.

2) You will want to make the changes to the Server already customized version of the php.ini file (the Server default php.ini file). Do not make a custom php.ini file with only the values you want to change or you will lose all the Server default modifications.

You can use this script to read the Server php.ini file, make your changes, and write it to your main directory:

Script to create a custom php.ini file (http://tips-scripts.com/php_ini)

Note: you can find the location of the default php.ini file on your server (to put in the script) by using the phpinfo() function (discussed above).

Server does not make frequent changes to the standard php.ini file, but you still may want to repeat the process once in a while. You could set the scripts to run via cron every night, then you would know you always have the latest revisions.

Note: "7200" is 2 hours in seconds


http://forums.site5.com/showthread.php?t=3689