This procedure describes how to compile a PHP extension. Zend Server includes over 77 extensions however there still may be a PHP extension that you want to compile by yourself.
Install the following packages:
Users of distributions with package managers (mainly Debian, Ubuntu, RHEL, CentOS and Fedora Core and many others) should install the following packages from their distribution's repository: gcc, make, autoconf, automake and libtool. Some of these tools depend on each other, for instance the libtool package depends on the gcc package, but no damage can be done from specifying all of them.
Note:
Users who utilize distributions that do not have package managers (Linux from scratch anyone?), can compile these tools themselves or obtain pre-compiled binaries for them quite easily.
Additionally, you can compile a PHP extension from the main PHP source (as opposed to PECL). This requires installing a package from the Zend Server repository called php-5.2-source-zend-server or php-5.3-source-zend-server, depending on your Zend Server's major PHP version. This package includes full PHP sources as patched, for security or optimization concerns, by the Zend development team. This ensures that you are using the exact same source code we used when building Zend Server.
Newt is a PHP extension for RedHat's Newt (New Terminal) library, a terminal-based window and widget library for writing applications with user friendly interfaces.
Being what it is, this extension requires the existence of the Newt library development files. If you are using Debian or Ubuntu you should install a package called libnewt-dev. On RedHat based distributions the package name is newt-devel. Make sure these are installed before continuing.
NOTE: Other extensions will have other dependencies. For example, the Mcrypt extension will require the Mcrypt development package.
NOTE: Since PECL will attempt to write the extension onto /usr/local/zend/lib/php_extensions, you will have to become a super user to perform this procedure. This is only needed for the actual make install.
|
|
To compile your own extension:
The truncated output of this command, along with explanations: PECL retrieves the package from the repository...*/ downloading newt-1.2.1.tgz Starting to download newt-1.2.1.tgz (24,853 bytes) .........done: 24,853 bytes 5 source files, building /*The phpize script is executed...*/ running: phpize Configuring for: PHP Api Version: 20041225 Zend Module Api No: 20060613 Zend Extension Api No: 220060519 building in /var/tmp/pear-build-root/newt-1.2.1 Configure comes into play running: /tmp/pear/download/newt-1.2.1/configure checking for grep that handles long lines and -e... /bin/grep checking for egrep... /bin/grep -E checking for a sed that does not truncate output... /bin/sed checking for gcc... gcc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o Next comes libtool. creating libtool appending configuration tag "CXX" to libtool configure: creating ./config.status config.status: creating config.h The actual compilation process: calls make which internally triggers GCC and LD. running: make /bin/sh /var/tmp/pear-build-root/newt-1.2.1/libtool --mode=compile gcc -I. -I/tmp/pear/download/newt-1.2.1 -DPHP_ATOM_INC -I/var/tmp/pear-build-root/newt-1.2.1/include -I/var/tmp/pear-build-root/newt-1.2.1/main -I/tmp/pear/download/newt-1.2.1 -I/usr/local/zend/include/php -I/usr/local/zend/include/php/main -I/usr/local/zend/include/php/TSRM -I/usr/local/zend/include/php/Zend -I/usr/local/zend/include/php/ext -I/usr/local/zend/include/php/ext/date/lib -I/usr/local/zend/include/php -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/download/newt-1.2.1/newt.c -o newt.lo mkdir .libs gcc -I. -I/tmp/pear/download/newt-1.2.1 -DPHP_ATOM_INC -I/var/tmp/pear-build-root/newt-1.2.1/include -I/var/tmp/pear-build-root/newt-1.2.1/main -I/tmp/pear/download/newt-1.2.1 -I/usr/local/zend/include/php -I/usr/local/zend/include/php/main -I/usr/local/zend/include/php/TSRM -I/usr/local/zend/include/php/Zend -I/usr/local/zend/include/php/ext -I/usr/local/zend/include/php/ext/date/lib -I/usr/local/zend/include/php -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/download/newt-1.2.1/newt.c -fPIC -DPIC -o .libs/newt.o /bin/sh /var/tmp/pear-build-root/newt-1.2.1/libtool --mode=compile gcc -I. -I/tmp/pear/download/newt-1.2.1 -DPHP_ATOM_INC -I/var/tmp/pear-build-root/newt-1.2.1/include -I/var/tmp/pear-build-root/newt-1.2.1/main -I/tmp/pear/download/newt-1.2.1 -I/usr/local/zend/include/php -I/usr/local/zend/include/php/main -I/usr/local/zend/include/php/TSRM -I/usr/local/zend/include/php/Zend -I/usr/local/zend/include/php/ext -I/usr/local/zend/include/php/ext/date/lib -I/usr/local/zend/include/php -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/download/newt-1.2.1/newt_vcall.c -o newt_vcall.lo gcc -I. -I/tmp/pear/download/newt-1.2.1 -DPHP_ATOM_INC -I/var/tmp/pear-build-root/newt-1.2.1/include -I/var/tmp/pear-build-root/newt-1.2.1/main -I/tmp/pear/download/newt-1.2.1 -I/usr/local/zend/include/php -I/usr/local/zend/include/php/main -I/usr/local/zend/include/php/TSRM -I/usr/local/zend/include/php/Zend -I/usr/local/zend/include/php/ext -I/usr/local/zend/include/php/ext/date/lib -I/usr/local/zend/include/php -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/download/newt-1.2.1/newt_vcall.c -fPIC -DPIC -o .libs/newt_vcall.o /bin/sh /var/tmp/pear-build-root/newt-1.2.1/libtool --mode=link gcc -DPHP_ATOM_INC -I/var/tmp/pear-build-root/newt-1.2.1/include -I/var/tmp/pear-build-root/newt-1.2.1/main -I/tmp/pear/download/newt-1.2.1 -I/usr/local/zend/include/php -I/usr/local/zend/include/php/main -I/usr/local/zend/include/php/TSRM -I/usr/local/zend/include/php/Zend -I/usr/local/zend/include/php/ext -I/usr/local/zend/include/php/ext/date/lib -I/usr/local/zend/include/php -DHAVE_CONFIG_H -g -O2 -o newt.la -export-dynamic -avoid-version -prefer-pic -module -rpath /var/tmp/pear-build-root/newt-1.2.1/modules newt.lo newt_vcall.lo -lnewt gcc -shared .libs/newt.o .libs/newt_vcall.o -lnewt -Wl,-soname -Wl,newt.so -o .libs/newt.so creating newt.la (cd .libs && rm -f newt.la && ln -s ../newt.la newt.la) /bin/sh /var/tmp/pear-build-root/newt-1.2.1/libtool --mode=install cp ./newt.la /var/tmp/pear-build-root/newt-1.2.1/modules cp ./.libs/newt.so /var/tmp/pear-build-root/newt-1.2.1/modules/newt.so cp ./.libs/newt.lai /var/tmp/pear-build-root/newt-1.2.1/modules/newt.la PATH="$PATH:/sbin" ldconfig -n /var/tmp/pear-build-root/newt-1.2.1/modules ---------------------------------------------------------------------- Libraries have been installed in: /var/tmp/pear-build-root/newt-1.2.1/modules Build complete.
running: find "/var/tmp/pear-build-root/install-newt-1.2.1" | xargs ls -dils 574096 4 drwxr-xr-x 3 root root 4096 Mar 30 20:45 /var/tmp/pear-build-root/install-newt-1.2.1 574119 4 drwxr-xr-x 3 root root 4096 Mar 30 20:45 /var/tmp/pear-build-root/install-newt-1.2.1/usr 574120 4 drwxr-xr-x 3 root root 4096 Mar 30 20:45 /var/tmp/pear-build-root/install-newt-1.2.1/usr/local 574121 4 drwxr-xr-x 3 root root 4096 Mar 30 20:45 /var/tmp/pear-build-root/install-newt-1.2.1/usr/local/zend 574122 4 drwxr-xr-x 3 root root 4096 Mar 30 20:45 /var/tmp/pear-build-root/install-newt-1.2.1/usr/local/zend/lib 574123 4 drwxr-xr-x 2 root root 4096 Mar 30 20:45 /var/tmp/pear-build-root/install-newt-1.2.1/usr/local/zend/lib/php_extensions 574118 244 -rwxr-xr-x 1 root root 241717 Mar 30 20:45 /var/tmp/pear-build-root/install-newt-1.2.1/usr/local/zend/lib/php_extensions/newt.so Build process completed successfully Installing '/usr/local/zend/lib/php_extensions/newt.so' install ok: channel://pear.php.net/newt-1.2.1
|
|
Ensure the extension is properly loaded by checking the output of PHP Info. This can be viewed in the Zend Server PHP Info page. The extension will now appear in your Administration Interface under Server Setup | Extensions from which you can also load and unload the extension (for more information see: Working with Extensions). |
Pspell (Portable Spell Checker Interface Library) provides a generic interface to the system spelling checking libraries. To compile PSpell first install the php-source-zend-[ce|pe] package for this procedure. Also, since this extension relies on the portable spell-checking interface (pspell) library, you will need to install its devel package. Debian and Ubuntu users should install the libpspell-dev package, on RedHat based distributions, the package name is aspell-devel.
|
|
To compile your own extension:
The output should be similar to this: /Configuring for: PHP Api Version: 20041225 Zend Module Api No: 20060613 Zend Extension Api No: 220060519/
The output should be: /Installing shared extensions: /usr/local/zend/lib/php_extensions/
|
|
Ensure the extension is properly loaded by checking the output of PHP Info. This can be viewed in the Zend Server PHP Info page. The extension will now appear in your Administration Interface under Server Setup | Extensions from which you can also load and unload the extension (for more information see: Working with Extensions).
Troubleshooting: The configure script outputs messages as it goes along and many times you will be able to understand the problem just by looking at it, however, sometimes, the error doesn't necessarily reflect the real issue so it is always a good idea to review the config.log. This is a very generic statement but no other statement can be made as there are many different extensions and issues one may come across so attempting to list them all will be somewhat futile. |
|
|
Related Links: PHP Extension ListAdding Extensions |
|
|
|