Automatic installer
There is no official installer which will configure PHP4 to work with Apache server. You may run the installer if you wish, using the following data where appropriate.
- directory = C:\php4
- smtp server = localhost
- email = me@localhost
- install for Apache2
If PHP is not configured, skip the installation step and follow the rest of the guide.
Here is a rare unofficial installer which will configure Apache. Since you might not have this installer, the shown process is more academic than practical.
Click the installer to start
Note: Use actual data in the following lines if you have a SMTP server.
Key in localhost as SMTP server.
Key in me@localhost as email address.
Select Apache2 or your HTTP server
A notice from the installer. Get ready to tell the installer where httpd.conf is.
Click OK.
Find and highlight httpd.conf. In case you have forgotten, it is in C:\Apache2\conf.
Click Open.
Accept the installation directory (recommended) or change it
Accept program group creation
Click Next to finish the installation process
You might be told to reboot Windows. Do as you are told.
If you are not told to reboot Windows, restart Apache service.
Manual Installation:
Download a zipped binary PHP4 package from www.php.net.
Unpack it to C:\ and rename the directory C:\php4. Do not retain the original long name unless you enjoy remembering and typing numbers.
Copy php.ini.recommended (preferred) or php.ini.dist in C:\php4\php to C:\Windows and rename it php.ini.
Copy php4ts.dll in the same (or dll folder) to C:\Windows\System32.
Configuring PHP4 with Apache:
Open php.ini with Notepad.
- Next find session.save_path= and add "C:/php4/sessions" (with quotes). Make sure that directory exist, create if necessary.
- Go further down the file and look for smtp = localhost and sendmail_from = me@localhost. If you find them, well and good. If not, edit to those values.
- Save the file. You may edit other settings if you wish.
Go to C:\apache2\conf and open httpd.conf with Notepad.
- Look the section where LoadModule lines are, add a new line with the text
LoadModule php4_module c:/PHP/sapi/php4apache2.dll
|
- Find the section where AddType application lines are, add a new line with the text
AddType application/x-httpd-php .php .php3 .phtml .php4
|
If you have problem finding those sections, just go the end of httpd.conf and add those two new lines.
Find the line DirectoryIndex, add index.php at the end of the line. You may order the sequence any way you want.
Save
Restarting Apache
Open the DOS window, cd to c:\apache2\bin and issue the command apache -k stop and then apache -k start. (apache -k restart does both.)
If you do not see any error message, PHP has been installed and configured correctly. If you do, take note of the message and try to solve the problem.
Alternatively, stop and restart Apache service in Windows Services. This is an easier way but it does not give you as much information when Apache fails to start.
Testing PHP:
Create a file using Notepad with the text <? phpinfo(); ?> and save it as "test.php" (with quotes). [This save with double quotes trick is to force Notepad not to insert the .txt file extension.]
Copy or move test.php to the web root directory C:\apache2\htdocs.
Start your favourite browser. Type http://localhost/test.php and you should see tables displaying the inner secrets of your computer and servers.
Warning: Delete test.php from web root after the test.
A bonus for you
Here is a more elaborate test script. If you do not know what refresh button is, hit F5 (both Linux and Windows).
Q&A
Why is PHP not configured for MySQL?
MySQL support is activated by default.
|