Compiling PHP for 64 bits on Solaris 10 with Sun Studio
PHP is a popular programming language for the Web. Many applications are now available to leverage Apache, MySQL and PHP (often referred to as the AMP stack). Solaris 10 running in 64 bits ships with 32 bit versions of these applications. LiveTime prefers to use highly optimized, shared library versions. Instructions on how to to build Apache and MySQL for 64 bits are available in previous articles. Instructions on how to build PHP in 64 bits for AMD and Intel processors running on Solaris 10 is detailed below.
These build instructions assume that a 64 bit version of Apache has been installed in the default location on Solaris as detailed previously. These instructions are based on PHP 5.3, which includes a new native MySQL extension rather than relying on the MySQL client adapter present in earlier versions. This new extension offers the same backwards compatibility as earlier versions but improves performance and decreases memory requirements, since the rows are only cached at a single level instead of two with the previous model. The process of building PHP on Solaris 10 is also simplified and does not necessarily require the presence of MySQL for compilation.
These instructions have been updated to reflect Sun Studio 12, Update 1 which introduces parallelization, as well as support for compiling in the PHP GD Library. We assume that the appropriate dependencies for GD, namely, JPEG, PNG and Freetype have been installed from the Sun packages, including the development headers of each.
Download the PHP source from php.net and extract the contents into your build folder. Use the following options to compile PHP and install.
shell> CC="/opt/sunstudio12.1/bin/cc" CFLAGS="-xtarget=generic -m64 -xO4" CXX="CC" CXXFLAGS="-xtarget=generic -m64 -xO4" LDFLAGS="-m64" ./configure --with-apxs2=/usr/apache2/bin/apxs --prefix=/usr/local/php5 --with-config-file-path=/usr/local/php5/etc --enable-ftp --with-zlib-dir --enable-mbstring --enable-exif --enable-sockets --with-xmlrpc --enable-soap --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir shell> gmake shell> gmake install shell> cp php.ini-production /usr/local/php5/etc/php.ini
Finally ensure that the appropriate Apache configuration directives have been applied and start Apache to ensure that it starts up without errors.