First of all, open a command line and type (or copy & paste the bits of code, one line at a time)
-
sudo apt-get install build-essential subversion php5-cli php5-dev libgtk2.0-dev libglade2-dev libcairo2-dev re2c
then…
svn co http://svn.php.net/repository/pecl/cairo/trunk pecl-cairo
cd pecl-cairo
phpize
./configure
make
sudo make install
then…
svn co http://svn.php.net/repository/gtk/php-gtk/trunk php-gtk
cd php-gtk
cat /usr/share/aclocal/ltoptions.m4 /usr/share/aclocal/ltversion.m4 /usr/share/aclocal/ltsugar.m4 /usr/share/aclocal/lt~obsolete.m4 >> aclocal.m4
./buildconf
./configure
make
sudo make install
Finally, because in Ubuntu Lucid, /etc/php5/cli/conf.d/ and /etc/php5/apache2/conf.d/ are symlinks to /etc/php5/conf.d/ This means that if you install php_gtk2 in this directory, it will also load when php is run from Apache, causing server to crash, so…
sudo rm /etc/php5/cli/conf.d
sudo mkdir /etc/php5/cli/conf.d
sudo cp /etc/php5/conf.d/*.ini /etc/php5/cli/conf.d/
then…
echo "extension=/usr/lib/php5/20090626/php_gtk2.so" | sudo tee /etc/php5/cli/conf.d/php_gtk2.ini
echo "extension=/usr/lib/php5/20090626/cairo.so" | sudo tee /etc/php5/cli/conf.d/cairo.ini
Then, to check it has loaded correctly:
php -m | grep php-gtk
Thanks to this thread for the info. If anyone knows how to turn this into a .deb file for easy installation, I’d be happy to host it on here.
Related posts:



#1 by Billy Bob on July 3, 2010 - 9:24 pm
bill@paul-linux-desktop:~/pecl-cairo/pecl-cairo/php-gtk$ /usr/share/aclocal/ltsugar.m4 /usr/share/aclocal/lt~obsolete.m4 >> aclocal.m4
bash: /usr/share/aclocal/ltsugar.m4: Permission denied
Then
bill@paul-linux-desktop:~/pecl-cairo/pecl-cairo/php-gtk$ ./buildconf
rebuilding config.h.in
configure.in:150: warning: LTOPTIONS_VERSION is m4_require’d but not m4_defun’d
aclocal.m4:2941: LT_INIT is expanded from…
aclocal.m4:2976: AC_PROG_LIBTOOL is expanded from…
configure.in:150: the top level
configure.in:150: warning: LTSUGAR_VERSION is m4_require’d but not m4_defun’d
configure.in:150: warning: LTVERSION_VERSION is m4_require’d but not m4_defun’d
configure.in:150: warning: LTOBSOLETE_VERSION is m4_require’d but not m4_defun’d
next
bill@paul-linux-desktop:~/pecl-cairo/pecl-cairo/php-gtk$ ./buildconf
rebuilding config.h.in
configure.in:150: warning: LTOPTIONS_VERSION is m4_require’d but not m4_defun’d
aclocal.m4:2941: LT_INIT is expanded from…
aclocal.m4:2976: AC_PROG_LIBTOOL is expanded from…
configure.in:150: the top level
configure.in:150: warning: LTSUGAR_VERSION is m4_require’d but not m4_defun’d
configure.in:150: warning: LTVERSION_VERSION is m4_require’d but not m4_defun’d
configure.in:150: warning: LTOBSOLETE_VERSION is m4_require’d but not m4_defun’d
bill@paul-linux-desktop:~/pecl-cairo/pecl-cairo/php-gtk$ sudo make install
make: *** No rule to make target `install’. Stop.
bill@paul-linux-desktop:~/pecl-cairo/pecl-cairo/php-gtk$ ./configure
checking for grep that handles long lines and -e… /bin/grep
checking for egrep… /bin/grep -E
checking for a sed that does not truncate output… /bin/sed
checking for cc… cc
checking whether the C compiler works… yes
checking for C compiler default output file name… a.out
checking for suffix of executables…
checking whether we are cross compiling… no
checking for suffix of object files… o
checking whether we are using the GNU C compiler… yes
checking whether cc accepts -g… yes
checking for cc option to accept ISO C89… none needed
checking how to run the C preprocessor… cc -E
checking for icc… no
checking for suncc… no
checking whether cc understands -c and -o together… yes
checking for system library directory… lib
checking if compiler supports -R… no
checking if compiler supports -Wl,-rpath,… yes
checking build system type… i686-pc-linux-gnu
checking host system type… i686-pc-linux-gnu
checking target system type… i686-pc-linux-gnu
checking for PHP prefix… /usr
checking for PHP includes… -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
checking for PHP extension directory… /usr/lib/php5/20090626+lfs
checking for PHP installed headers prefix… /usr/include/php5
checking if debug is enabled… no
checking if zts is enabled… no
checking for re2c… no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk… gawk
checking for PHP-GTK support… yes, shared
checking for PHP executable… found version 5.3.2-1ubuntu4.2
checking for gawk… (cached) gawk
checking whether to include debugging symbols… no
checking for pkg-config… /usr/bin/pkg-config
checking for GLIB – version >= 2.6.0… yes (version 2.24.1)
checking for pkg-config… (cached) /usr/bin/pkg-config
checking for GTK+ – version >= 2.6.0… no
*** Could not run GTK+ test program, checking why…
*** The test program failed to compile or link. See the file config.log for the
*** exact error that occured. This usually means GTK+ is incorrectly installed.
configure: error: PHP-GTK 2.x requires GTK+ 2.6.0 or higher
I’m running 10.04 32 bit ubuntu
I’ll Play some more and report back
#2 by gavomatic57 on July 3, 2010 - 10:56 pm
Hi Billy Bob. It sounds to me like you are confusing the pecl-cairo bit and the GTK bit.
Once you have typed the “svn co http://svn.php.net/repository/pecl/cairo/trunk pecl-cairo” bit, it’ll download the source code. You then cd into the new directory it would have created. cd pecl-cairo (then enter). Then type “phpize”. You can then go configure and make install. Once you have done that, you don’t need to refer to pecl-cairo again.
You then go onto the php section. “svn co http://svn.php.net/repository/gtk/php-gtk/trunk php-gtk” downloads the source code. You then cd into its directory – “cd php-gtk”
Then you’ve got one big line to copy & paste “cat /usr/share/aclocal/ltoptions.m4 /usr/share/aclocal/ltversion.m4
/usr/share/aclocal/ltsugar.m4 /usr/share/aclocal/lt~obsolete.m4 >> aclocal.m4″
It is all one line as I’ve marked out above.
You then do the ./buildconf and ./configure lines.
Hope this helps, but check out the forum thread I have linked to above. The guide worked for me on the 64bit version, but there may be some differences in the method for the 32bit version.