Installing Xdebug for use with Eclipse or Netbeans on Linux
Using PHP pspell Spell Check Functions with a Custom Dictionary
Development Resource Project
Book Review: How to Implement Design Patterns in PHP
Nice n' Easy JQuery Image Rotator
A Simple ISAPI Filter for Authentication on IIS

Compiling and Installing on Ubuntu Linux

Friday, 17 October 08, 8:34 pm

Compiling from .tar.gz

The archive contains the source code files and supporting resources (bitmaps etc). So we'll need to compile this to make our executable program.

First extract the archive somewhere. I use a subdirectory off my home called src:
cd ~/src tar -zxvf ~/download/newapp.tar.gz
If the archive is compressed with bzip (extension is .bz2), use option j instead of z:
cd ~/src tar -jxvf ~/download/newapp.tar.bz2
Then change to the newly extracted folder eg cd ~/src/newapp. Most source packages come with a configure script which you need to run before compilation. To compile using all defaults, just run these three commands:
./configure make sudo make install
A whole load of options can be passed to configure though, some are standard for all compilations, while others are specific to the application being compiled. To view the application-specific options that are available run:
./configure --help=short
To view all options, use --help. One good global option is the -q switch, for quiet, which skips printing all the checking... lines, making it easier to tell where any problems occur, if any.

It's quite likely that the configure script will error-out at least once, usually because it's detected a missing dependency. The last line of its output will be something like this:
configure: error: IMWheel depends on the XTest extention!
You'll need to find and install the missing package; searching on Google should get you through. Once configure completes successfully, which it will indicate simply by not ending with any error, you can run make.

This may also fail due to missing dependencies. To know which, you'll have to scroll up through various warning messages the compiler has spat out before you get to the error which actually caused it to halt compilation:
imwheel.c:26:29: error: X11/Xmu/WinUtil.h: No such file or directory
This message tells us that the error occurred on line 26, column 29, of the C source file imwheel.c, and that the problem is that it cannot find a particular header file. Out of interest, we can look at the indicated line of imwheel.c, and we see:
#include <X11/Xmu/WinUtil.h>
This is a C directive telling the compiler to import the X11/Xmu/WinUtil.h header file, and as you'd expect, it matches the error thrown by make.

The standard include location for C header files is /usr/include, and we can even check this to see that the header is truly not there (we all know how computers sometimes tell lies in order to put off doing any work for as long as possible).

It can be a bit harder finding the right package for your particular distro for missing files at this stage, and may take some perseverance for less popular ones. For this particular header on Ubuntu, we need to install libxmu-dev.

Once I had this, make failed again, this time with the message "undefined reference to `XmuClientWindow'". This appears to be somehow related to TeX, the electronic typesetting system, and also GPM (for General Purpose Mouse, a project for mouse support on Xterms I think). We can sidestep this error by running configure again, but disabling GPM support (or does it just disable making documentation for GPM? Don't know but it worked for me!):
./configure --disable-gpm-doc
make also signals its success by an absence of error messages (plenty of warnings though, this is normal). So we're ready to install, sudo make install. There shouldn't be any problems at this stage, as we've already compiled the executable successfully, so touch wood you'll then be good to go.

When you want to compile a new version, uninstall the old one first from the program's source directory, by running:
sudo make uninstall


11:14 am, Saturday, 25 October 08

With MySQL and Apache 2 already installed, here are the steps I followed to compile and install PHP. I followed the instuctions on this page (also covers compilation of MySQL and Apache) and repeat them here in case I need them again. First, I got a few supporting libraries:These can all be installed in the standard configuration, ie from the extracted source directory, run ./configure --prefix=/usr/local, then do make and sudo make install. The following exceptions apply: for libjpeg, run sudo make install-lib as an additional final step, and for libpng simply copy the linux makefile with cp scripts/makefile.linux makefile instead of running ./configure.

Once these were all installed, from the PHP source directory, I configured with this command:

./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/tmp/mysql.sock --with-sqlite --enable-sqlite-utf8 --with-zlib --with-zlib-dir --with-bz2 --with-gd --enable-gd --enable-gd-native-ttf --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-ttf --with-freetype-dir=/usr/local --with-iconv=/usr/local --with-curl=/usr/local --enable-track-vars --with-gettext --with-config-file-path=/usr/local/apache2/conf --enable-trans-id --enable-ftp --enable-mbstring

The final step is to copy the default php.ini file to the apache2 conf directory:

sudo cp php.ini-dist /usr/local/apache2/conf/php.ini

It can be edited as required, eg to disable magic quotes and increase the file upload limit. Run phpinfo() to check it's all up and running fine.
Leave Comment

/xkcd/ What to Bring

About This Page