PHP
From charlesreid1
Installation
Preqrequisites
I have built my PHP to work with Apache. I also build PHP to work with phpMyAdmin, which is a very nice and handy browser interface for MySQL databases. Building PHP to work with phpMyAdmin required installing the mcrypt library, which provides PHP with encryption libraries.
The mcrypt utility provides access to cryptographic functions, while libmcrypt is a library containing the actual cryptographic functions themselves.
Mcrypt: http://mcrypt.sourceforge.net/
Libmcrypt: http://freshmeat.net/projects/libmcrypt/
It's also imperative that you have a web server like Apache installed - otherwise you will only be able to use PHP from the command line, which isn't terribly useful. If you are using Apache, you must include the Apache PHP module in your Apache httpd.conf file. However, if you point PHP configure to your Apache installation (see next section), the command to load the PHP module should be automatically added to your httpd.conf file. Visit the Apache#PHP Module page for more details.
Configuration
The configure process for PHP has two parts. The first part is telling PHP which extensions to build, and the second is actually configuring/building. However, you can't actually do the first step until you do the second step - so you have to build PHP, then build the extensions.
The PHP configure line I use is:
#!/bin/sh
# run configure
# make
# make install
./configure \
--prefix=$HOME/pkg/php-5.3.0 \
--with-mysql=/usr/local/mysql \
--with-apxs2=$HOME/pkg/apache-2.2.11/bin/apxs \
--disable-cgi \
--with-zlib \
\
--enable-mbstring \
\
--enable-pdo \
--with-pdo-mysql=/usr/local/mysql \
\
--with-mcrypt=$HOME/pkg/libmcrypt-2.5.8 \
\
--enable-sockets
The mcrypt functionality, as well as the PDO and mbstring functionality, are required to get PHP working with phpMyAdmin. The apxs option is required to get PHP working with Apache. I included sockets because they're fun and interesting.
Then you run make and make install, and if you really want to, make test.
Now that you've installed PHP, you've also installed a utility called phpize, which allows you to install extensions. To build PHP extensions, you have to tell PHP configure that you want to build them. So go to the directory containing your configure file, then to a directory called ext. This contains PHP extensions.
/path/to/php/source/ext $ /bin/ls -1C
bcmath libxml session
bz2 mbstring shmop
calendar mcrypt simplexml
com_dotnet mssql skeleton
ctype mysql snmp
curl mysqli soap
date mysqlnd sockets
dba oci8 spl
dom odbc sqlite
enchant openssl sqlite3
ereg pcntl standard
exif pcre sybase_ct
ext_skel pdo sysvmsg
ext_skel_win32.php pdo_dblib sysvsem
fileinfo pdo_firebird sysvshm
filter pdo_mysql tidy
ftp pdo_oci tokenizer
gd pdo_odbc wddx
gettext pdo_pgsql xml
gmp pdo_sqlite xmlreader
hash pgsql xmlrpc
iconv phar xmlwriter
imap posix xsl
interbase pspell zip
intl readline zlib
json recode
ldap reflection
These are all the extensions that come with PHP. To build an extension when you build PHP, do this:
$ cd mcrypt
$ phpize
$ cd ../
You can phpize any extensions you want, but you'll have to include the corresponding configure option. For example, I can phpize mcrypt, but if I don't point PHP configure to my mcrypt library, then the phpize is useless. Likewise, if I point PHP configure to my mcrypt library, but don't phpize mcrypt, PHP doesn't do anything with the location to mcrypt.
Once you've phpized the extensions you want, you can go back to the source directory (where your configure script is located), run configure one more time, and then run make and make install. If you didn't run make clean in the meantime, it won't have to re-build PHP, it will only build the extensions.
Once you've built the extensions, you're good to go - you can enable the extensions in your PHP configuration file (below).
PHP Information
If you're ever unsure about the PHP settings, where configuration files are located, which extensions are installed, etc., then you can create a PHP file with any name (I use info.php), with the following PHP contents:
<?php
info();
?>
Then you can put this in your web directory, and go to http://localhost/info.php. This will output a bunch of information about your PHP install.
PHP Configuration File
The PHP configuration file is called php.ini. If you're not sure where it's located, use the above info() function - it will give you the location of your php.ini file.