PHP Ini Tweaks

This extract shows a few tweaks to ensure that PHP works the way you would expect. The examples are for windows and are related to 2 previous articles about Apache configuration.

In my previous articles, I showed how to enable PHP as an Apache module without relying on anything other than the standard Apache installer and how to run 2 versions of PHP on Apache for Windows.

In this article I cover some of the basic tweaks that will ensure that PHP will run as you expect it to and assumes that you have installed PHP as suggested in my previous articles:

Mail settings have already been covered in this article. However, if you want to have multiple instances of PHP or just make the installation cleaner, then lets assume you have extracted the PHP files into
X:/Program Files/Apache Group/php/php-5.2.0-Win32 and
X:/Program Files/Apache Group/php/php-6.0.0-Win32.

Aside from the mail settings, the main configuration setting that needs to be modified is the extensions directory. This enables PHP to look in the correct directory for extensions that are to be loaded on start-up. In PHP5 and above this extensions reside in the INSTALL_DIR/ext directory.

Therefore, in your php.ini file, point the directory to the install directories extension path:

extension_dir = "X:/Program Files/Apache Group/php/php-5.2.0-Win32/ext/"
# OR FOR PHP 6
extension_dir = "X:/Program Files/Apache Group/php/php-6.0.0-Win32/ext/"

Other settings that can/should be tweaked are:

  • Temp directories
  • Extensions directories
  • Include path
  • Document Root

doc_root setting is something that may or may not make a difference to your set up. You can leave it as is, or change it to your servers document root.

doc_root = "X:/Program Files/Apache Group/Apache2/htdocs"

Temp directories are important as PHP uses the system temp directories unless otherwise stated. I created a temp directory in my Apache Group folder and pointed upload_tmp_dir and session.save_path to this directory.

upload_tmp_dir = "X:/Program Files/Apache Group/tmp"
session.save_path = "X:/Program Files/Apache Group/tmp"

One final step related to PHP is to set your path in your computer’s system variables. This can be done by opening up SYSTEM PROPERTIES by right clicking on your “My Computer” icon on your desktop. Click on the ADVANCED tab. You should now see a couple of buttons towards the bottom of the screen. Press the ENVIRONMENT VARIABLES button.

In the bottom of the two areas displayed, highlight path. This will, or should at least, contain things like %SystemRoot%\system32; and other paths separated by ;. At the end of the list add the following noting the ; at the beginning as the separator.

;X:\Program Files\Apache Group\php\php-5.2.0-Win32

Note that I specified PHP5 here as that is the main installation for me in this instance.

Reboot your server and you should see all the changes in effect.

Source: http://www.skiffie.com/code/server/php-configuration.

Post a Comment

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word