Greg's Blog

helping me remember what I figure out

PHP Config Tips

| Comments

1/ The first problem I came across was working with session variables. For some reason during the PHP installation the default directory for storing the session information had been set ”/tmp” which is of course a Unix style path and didn’t exist on my system and hence threw an error. You can change this path by locating you php.ini file. By default this is stored in your Windows folder on your system drive. Once located open it up and look for session.save_path. Replace the /tmp with the desired location for your session data. In fact there should be a folder in your PHP labelled sessiondata, so you might as well set it to that. Your .ini file should look something like this assuming that you have installed into the root of your C Drive:

session.save_path = c:\PHP\sessiondata

If you have loaded PHP as module in Apache, you will need to stop and restart your Apache server.

2/ The next problem I had was with PHP generated e-mails. They simply couldn’t be sent at this stage I can’t recall what the error message was or even whether there was an error message. All I remember is not receiving the messages. Again you will need to look into your php.ini file. Look for the following segment:

[mail function]
; For Win32 only.
SMTP =localhost

; For Win32 only.
sendmail_from =me@localhost.com

Again this should probably work just fine on a UNIX or windows box running a mail or SMTP server, but I was not so fortunate. I could have downloaded and installed the ArgoSoft freeware mail server, but instead chose to use the SMTP server address provided by my ISP, because I was pretty much always on-line. So simply edit the line to look something like this:

[mail function] ; For Win32 only. SMTP =mail.yourISPsSMTPserver.com ; For Win32 only. sendmail_from =yourname@server.com

I also edited the ”sendmail_from” line, because messages sent other wise via the server tend to display nothing in the FROM: field in your mail client. AGain if you have PHP installed as a module for Apache you will need to restart the Apache server.

3/ On certain windows installations PHP just wouldn’t recognise submitted form fields. The work around for this can also be found in your php.ini. Locate the section labelled: Data Handling, there you will find the following line:

register_globals = Off

Simply set that value to On and restart your web server and the problem disappears.

4/ Configuring Apache2 to use PHP on a Windows box is sadly not automated either. So you’ll need to open your httpd.conf file and add the following lines to it:

#PHP 4 config info
LoadModule php4_module “c:/php/sapi/php4apache2.dll”
AddType application/x-httpd-php .php

Once you have entered these lines, save and restart your web server for the changes to take effect. You can read more about Apache2 configuration here.