NOTE: This is considered an Expert Only change. This change, if done incorrectly or if there are special circumstances on your site, can disable your site. These instructions are meant as a guideline and further research on your part may be required if this change doesn't result in the desired outcome.

A lot of customers submit tickets for us to make a modification to the global php.ini file to accommodate a script they are installing. As you can imagine on a shared server, this is both insecure, impractical and doesn't provide us good configuration management practices.

In this case, where one customer needs the settings 'register_globals' turned off and another customer needs it turned on - of course these are conflicting requirements and we cannot globally turn it off without affecting the scripts of customers who need the setting turned to on. So, how do we make everyone happy?

Our Apache/PHP configuration permits customers to define php.ini settings so it only affects his/her website/PHP based script. Once you determine what settings you need that differ from our global php.ini all you need to do is place those settings within a php.ini file that you upload to the location where your PHP script resides. Lets look at an example:

You have a script 'myscript.php' that requires the following settings according to the documentation -

1. register_globals need to be turned on

2. safe_mode needs to be turned off

3. enable_dl needs to be turned on

In this example the script 'myscript.php' resides within your public_html/ directory.

1. Open up a text editor such as the free TextWrangler (http://www.barebones.com/products/textwrangler/) on your computer (not TextEdit - which may incorrectly format your php.ini file) and add the following:

register_globals = On
safe_mode = Off
enable_dl = On

2. Save that file with the name 'php.ini'

3. Upload that file to public_html/ (or whichever directory your script resides in)

You will also need to create or edit the .htaccess file in that directory.

 

4. Open up a text editor such as the free TextWrangler (http://www.barebones.com/products/textwrangler/) on your computer (not TextEdit - which may incorrectly format your php.ini file) and add the following:

 

<IfModule mod_suphp.c>

suPHP_ConfigPath /home/USERNAME (Replace USERNAME with your main FTP username)

<Files php.ini>

order allow,deny
deny from all

</Files>

</IfModule>

 

5. Save the file as htaccess and upload it to the directory where your php.ini file is loaded.

 

6. Once uploaded, change the name of the file on the server to .htaccess (this will activate the file and also make it invisible on the server)

Simple, now you have a custom php configuration!

Kas see vastus oli kasulik? 21 Kasutajad peavad seda kasulikuks (61 Hääled)