At the moment there are some minor problems when trying to get a working installation of PHP with GTK running on Ubuntu based systems. Here is a quick walk through of how you can get this all set up with the trunks from GTK and Cairo and the official package for php-cli in 10 easy steps. This installation was originally done on Linux Mint 9 but should work with most Ubuntu based Linux distributions.
- First of all install all the required packages, for this run the following command:
This will get you the current official package for PHP5 (5.3.2 at the time of writing) and then install all the things you need to build your Cairo and PHP-GTK extensions.
florian ~ $ sudo apt-get install php5-cli php5-dev libcairo2-dev libgtk2.0-dev
- After these have been installed, go to your home directory and checkout the latest Cairo and PHP-GTK trees from SVN:
- Next build and install the Cairo extension, you need to do this first because it is a dependancy of PHP-GTK. For this do the following:
florian ~ $ cd cairo/
florian ~/cairo $ phpize
florian ~/cairo $ ./configure
- Now you need to apply a little fix to the Makefile for Cairo to compile successfully (this is from Matthew Turland). Just open
~/cairo/Makefile with a text editor (nano or gedit, for example) and then find the line
CFLAGS = -g -O2 and replace it with this:
CFLAGS = -g -O2 -DCOMPILE_DL_CAIRO.
- Now you are ready to compile the Cairo extension, for this run make and make install like so:
Done. You have now successfully built the Cairo extension for php.
florian ~/cairo $ make
florian ~/cairo $ sudo make install
- Next you need to compile PHP-GTK. For this to work you will first need to apply a patch to the source tree, because there are some issues with the locations and names of the m4 libraries. Create the new file
~/php-gtk/ubuntu-fix.patch with the following content (this is from Bob Majdak):
diff -ur php-gtk/build2/build2.mk php-gtk-bob/build2/build2.mk
--- php-gtk/build2/build2.mk 2005-10-10 14:34:39.000000000 -0400
+++ php-gtk-bob/build2/build2.mk 2009-01-05 10:46:29.000000000 -0500
@@ -10,6 +10,7 @@
aclocal.m4: configure.in acinclude.m4
@echo rebuilding $@
+ cat /usr/share/aclocal/lt~obsolete.m4 /usr/share/aclocal/ltoptions.m4 /usr/share/aclocal/ltsugar.m4 /usr/share/aclocal/ltversion.m4 >> ./build/libtool.m4
cat acinclude.m4 ./build/libtool.m4 php_gtk.m4 > $@
- After saving, run the following two commands inside the
This will make sure PHP-GTK can find the libtool libraries it needs.
florian ~/php-gtk $ patch -Np1 --ignore-whitespace -i ./ubuntu-fix.diff
florian ~/php-gtk $ patch -Np2 -F13 -ignore-whitespace -i ./ubuntu-fix.diff
- Now we can build the php-gtk extension. For this you have to run
configure followed by the
make. For this use the following commands:
Done. You have (hopefully) successfully built the latest PHP-GTK extension.
florian ~/php-gtk $ ./buildconf
florian ~/php-gtk $ ./configure
florian ~/php-gtk $ make
florian ~/php-gtk $ sudo make install
- The only thing left to do now is make PHP actually load the two new libraries. For this you will need to locate your php.ini, you can find out where this is by running
php --ini from the terminal. Normally you will however find it in
/etc/php5/cli/php.ini. Open this as root, for example with
Here find the line
florian ~ $ sudo nano /etc/php5/cli/php.ini
florian ~ $ sudo gedit /etc/php5/cli/php.ini
; Dynamic Extensions ; and at the bottom of the section that is following it (All the lines beginning with ";" are comments, they should explain you how to load extensions) append the following:
; PHP-GTK 2
- Check that PHP does load the extensions as should be by running
php -m which shows you a list with all the loaded modules, these should now include cairo and
php-gtk. If this is all fine go and clean up your home directory, for this just do the following:
florian ~ $ rm -rf ~/cairo
florian ~ $ rm -rf ~/php-gtk
Congratulations, you are all done! Now go and enjoy your new PHP-GTK beauty!