| 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:
g++ version 3.4.0 or higher
make
Boost version 1.34 or higher
PHP5 embed SAPI (version 5.2.x recommended; refer to PHP embed SAPI installation instructions for more details). This is required to compile PHP code with phc.
Xerces-C++ if you want support for XML parsing (you don't need Xerces for XML unparsing).
Boehm garbage collector is used in phc, but not in code compiled by phc. If unavailable, it can be disabled with --disable-gc, but phc will leak all memory it uses.
The following dependencies are optional:
a DOT viewer such as graphviz if you want to be able to view the graphical output generated by phc (for example, syntax trees)
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.
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.6, the latest version available at time of writing. To extract PHP,
tar zxvf php-5.2.6.tar.gz
This will create a new directory php-5.2.6. 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 with the command
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. (There is a known bug, and long work-around for OSX already filed in the PHP bug system).
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
cd phc-0.2.0 ./configure make
(Consult ./configure --help for configuration options, if your dependencies are not in standard locations). 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. 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.