Warning
These instructions only apply if you don’t intend to modify phc, and you are using a downloaded phc release. If you intend to modify it, or you are using the phc SVN repository, please refer to the instructions for developers.
phc needs a Unix-like environment to run (it has been tested on Linux, Solaris, FreeBSD, Cygwin and Mac OS X). To compile phc, you will need:
The following dependencies are optional:
Under Debian/Ubuntu, the following command will install nearly all dependencies:
apt-get install build-essential libboost-dev libxerces27-dev graphviz libgc-dev
You will still need to install the PHP embed SAPI manually.
If you do not intend to compile PHP code using phc, you may skip this section.
If you intend to hack on phc, you should look at Building PHP for phc development.
In order to compile code, phc must have the PHP embed SAPI available, which is typically not available via standard package managers. The embed SAPI is also required for compiling stand-alone executables.
Download the PHP source (.tar.gz) package from php.net. We will assume you downloaded PHP version 5.2.10, the latest version available at time of writing. To extract PHP,
tar zxvf php-5.2.10.tar.gz
This will create a new directory php-5.2.10. In order to configure and compile PHP, you must know what configuration options you require. These are likely to be the same as the version of PHP you are currently using, which can be examined using the following command [3]
php -i | grep Configure
We will assume these options are --enable-bcmath --with-gmp --with-mysql, a configuration which we occasionally use for benchmarking. You are ready to build PHP. When configuring, you must add the --enable-embed option.
CFLAGS="-O3" ./configure --enable-bcmath --with-gmp --with-mysql --enable-embed
make
If this command does not succeed, there is a problem with PHP on your system, and you should file a bug report with the PHP group [1].
The most important part of the command is --enable-embed. While the CFLAGS="-O3" environmental variable is optional, we find it speeds up the executable by about four times. If PHP is already installed on your system, you may want to install this version separately, using the --prefix option. Other configuration options are discussed in the developer manual. Finally, install the embed SAPI:
make install
First of all, you must download the latest release of phc. To extract phc,
tar zxvf phc-0.2.0.tar.gz
This will create a new directory phc-0.2.0 that contains the phc source tree. Finally, you must compile phc. If the dependencies are in their standard locations, you should be able to simply type [2]
cd phc-0.2.0
./configure
make
This should compile without any warnings or errors. If this step fails, please send a bug report to the mailing list with as much information about your system as you can give, and we will try to resolve it. If you wish to test your build of phc, please see Test-suite. Finally, install phc using
make install
For information on running phc, see Running phc. If you can follow those instructions and you get the output you should get, congratulations! You have successfully installed phc.
If building from phc‘s subversion repository, it is important to run
touch src/generated/*
before make.
If ./configure is not able to find your Boost libraries, try using a path like
--with-boost=/opt/local
or
--with-boost=/usr
Alternatively, users have had success with symlinking the boost libraries into a standard location, like /usr/include/.
| [1] | There is a known bug, and long work-around for OSX already filed in the PHP bug system. |
| [2] | Consult ./configure –help for configuration options, if your dependencies are not in standard locations. |
| [3] | This line may not be present in some cases. If not, you may wish to find out how PHP is configured through some other means, such as looking up the source in your package manager. However, it is not necessary, and you may just assume there are no options. Alternatively, you may look through ./configure –help to deterine the options for yourself. |