Enabling GD Support

   

GD support is not enabled by default. You must enable the extension if you are using Windows, or compile-in/link the extension if you are using Linux.

Enabling GD for Windows

Enabling GD support for Windows is very easy, since the DLL file for GD has been pre-compiled and included in the basic PHP Windows installation. Open your php.ini file in a text editor and search for the line that says:

 extension_dir =  ./  

This line should point to the place where your PHP extensions reside. If you copied the extensions to the same directory as the php.ini file, then you do not need to modify the line. If you did not move the PHP extensions to the same directory as the php.ini file, then you need to edit the line to point to the correct directory, for example:

 extension_dir = C:\Apache\php\extensions  

Next, find the section in the php.ini file that says:

 ;Windows Extensions  

This line will be followed by many lines of Windows .dll extensions for PHP. To enable GD support, uncomment the line (delete the semicolon at the beginning of the line) that contains the GD library DLL:

 extension=php_gd.dll  

After you have uncommented the line, save the file and restart the Apache Web server.

You can verify the GD has been correctly installed by using the phpinfo(); as seen in Figure 11-1.

Figure 11-1. phpinfo() results with GD enabled for Windows

graphics/11fig01.jpg

Enabling GD for Linux

If you compiled PHP using Apache's APXS functionality (compile --with-apxs=/path/to/apache/bin/apxs), then adding functionality to the PHP module is a breeze.

Before recompiling PHP, I first suggest that you delete the config.cache file and clean up files left over from the previous compile. This can be done as follows:

 cd /path/to/php/source  rm config.cache make clean 

After you issue the make clean command, you will notice quite a few files being deleted. Don't worry about it. The make program is just cleaning up files it won't need when you recompile. If you don't run the make clean command, then you may start running into some problems. If you have been compiling PHP with no problems and suddenly it won't compile right even though you haven't changed anything, it's a good bet that the make clean command will solve your problem.

Once you've cleaned up the mess from the previous compile, you can get started with the new compile.

To compile PHP with GD support enabled:

 ./compile --with-apxs=/usr/local/apache/bin/apxs \  --with-gd \ --with-gd-native-ttf \ --with-ttf 

After the configure runs, issue the command:

 make  

Assuming no errors occur, you can then issue the command:

 make install  

The final command copies the libphp4.so library file to /path/to/apache/libexec/.

Restart Apache to load the new library:

 /path/to/apache/bin/apachectl restart  

You can verify the GD has been correctly installed by using the phpinfo() function.


   
Top


Advanced PHP for Web Professionals
Advanced PHP for Web Professionals
ISBN: 0130085391
EAN: 2147483647
Year: 2005
Pages: 92

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net