Sunday, May 08, 2005

Enabling GD in windows for php

There was no clear cut document for the issues I faced today. So, I am writing this for my own reference also. This document is intended for php version 4.3.x and above running on Apache2 and the gd bundled with php itself.

Make sure after installing/untarring the php in a location other than server root/document root. Create a directory called php under c:/ and copy the following files to php4apache2.dll, php4ts.dll, php.exe and php.ini (php.inst-dist from the php installation dir).

Enable php in apache. Open the httpd.conf in your favourite editor (vim) and add index.php to DirectoryIndex directive.
DirectoryIndex index.html index.html.var index.php

Add another line to addType directive in httpd.conf
AddType application/x-httpd-php .php

Load the php SAPI as a module by adding this in httpd.conf
LoadModule php4_module “c:/php/php4apache2.dll”

Edit the php.ini file accordingly. The following should be updated. extensions should point to the extensions dir inside the php installation dir. If temp is not present, create temp folder.
doc_root = c:\apache\apache2\htdocs
extension_dir = c:\php\extensions
session.save_path = c:/temp

Uncomment the following line in php.ini.
extension=php_gd.dll

Finally copy the php.ini file to c:/windows dir.

Write a php file with the contents as below to check.
var_dump(gd_info());



No comments: