old-www/HOWTO/Apache-Compile-HOWTO/phpext.html

459 lines
7.9 KiB
HTML

<HTML
><HEAD
><TITLE
>PHP extensions</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="Apache Compile HOWTO"
HREF="index.html"><LINK
REL="PREVIOUS"
TITLE="mod_php and its prerequisites"
HREF="php.html"><LINK
REL="NEXT"
TITLE="Jakarta Tomcat"
HREF="tomcat.html"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Apache Compile HOWTO</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="php.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="tomcat.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="PHPEXT"
></A
>7. PHP extensions</H1
><P
>There are many different extensions available for php, which can be added in your php.ini</P
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN790"
></A
>7.1. APC (Alternative PHP-cache)</H2
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="AEN792"
></A
>7.1.1. What is APC</H3
><A
NAME="AEN794"
></A
><TABLE
BORDER="0"
WIDTH="100%"
CELLSPACING="0"
CELLPADDING="0"
CLASS="BLOCKQUOTE"
><TR
><TD
WIDTH="10%"
VALIGN="TOP"
>&nbsp;</TD
><TD
WIDTH="80%"
VALIGN="TOP"
><P
>APC is the Alternative PHP Cache. It was conceived of to provide a free, open, and robust framework for compiling
and caching php scripts. APC was conceived of to provide a way of boosting the performance of PHP on heavily loaded sites
by providing a way for scripts to be cached in a compiled state, so that the overhead of parsing and compiling can be
almost completely eliminated. There are commercial products which provide this functionality, but they are neither
open-source nor free. Our goal was to level the playing field by providing an implementation that allows greater
flexibility and is universally accessible. We also wanted the cache to provide visibility into it's own workings and
those of PHP, so time was invested in providing internal diagnostic tools which allow for cache diagnostics and
maintenance. Thus arrived APC. Since we were committed to developing a product which can easily grow with new version
of PHP, we implemented it as a zend extension, allowing it to either be compiled into PHP or added post facto as a
drop in module. As with PHP, it is available completely free for commercial and non-commercial use, under the same terms
as PHP itself. APC has been tested under PHP 4.0.3, 4.0.3pl1 and 4.0.4. It currently compiles under Linux and FreeBSD.
Patches for ports to other OSs/ PHP versions are welcome.</P
></TD
><TD
WIDTH="10%"
VALIGN="TOP"
>&nbsp;</TD
></TR
><TR
><TD
COLSPAN="2"
ALIGN="RIGHT"
VALIGN="TOP"
>--<SPAN
CLASS="ATTRIBUTION"
>www.apc.communityconnect.com/</SPAN
></TD
><TD
WIDTH="10%"
>&nbsp;</TD
></TR
></TABLE
><P
>The author made some performance-Tests with apc and it was real surprise. A PHP-Webpage with
MySQL-queries in a loop (total 10 queries) was more than 50% faster </P
><P
>Contra APC: If you have other users on the system coding php they maybe are not comfortable with APC,
because the changes are all ignored unless you reset the cache or restart Apache. The other way,
namely that APC checks the php-script for a newer version before every run costs speed.</P
></DIV
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="AEN799"
></A
>7.1.2. Download the source</H3
><P
>Origin-Site: <A
HREF="http://apc.communityconnect.com/sources/apc-cvs.tar.gz"
TARGET="_top"
>http://apc.communityconnect.com/sources/apc-cvs.tar.gz</A
></P
></DIV
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="AEN803"
></A
>7.1.3. Building and installing</H3
><TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>cd /usr/local
tar -xvzf apc-cvs.tar.gz
cd apc
./configure --enable-apc --with-php-config=/usr/local/bin/php-config
make
make install
cp modules/php_apc.so /usr/local/lib/php/extensions
echo 'zend_extension="/usr/local/lib/php/extensions/php_apc.so"' \
&#62;&#62; /usr/local/lib/php.ini
echo &#8220;apc.mode = shm&#8221; &#62;&#62; \
apc.mode = shm</PRE
></FONT
></TD
></TR
></TABLE
><P
>Restart your Apache-Webserver. Try it out, create a php-file with the following content: </P
><DIV
CLASS="EXAMPLE"
><A
NAME="AEN807"
></A
><P
><B
>Example 7. apctest.php</B
></P
><TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>&#60;?php
apcinfo();
?&#62;</PRE
></FONT
></TD
></TR
></TABLE
></DIV
></DIV
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN810"
></A
>7.2. Zend-Optimizer (Do _NOT_ combine with APC-Cache!)</H2
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="AEN812"
></A
>7.2.1. What is Zend-optimizer</H3
><A
NAME="AEN814"
></A
><TABLE
BORDER="0"
WIDTH="100%"
CELLSPACING="0"
CELLPADDING="0"
CLASS="BLOCKQUOTE"
><TR
><TD
WIDTH="10%"
VALIGN="TOP"
>&nbsp;</TD
><TD
WIDTH="80%"
VALIGN="TOP"
><P
>The Zend Optimizer goes over the intermediate code generated by the standard Zend run-time compiler
located in the Zend Engine, and then optimizes it for faster execution. </P
></TD
><TD
WIDTH="10%"
VALIGN="TOP"
>&nbsp;</TD
></TR
><TR
><TD
COLSPAN="2"
ALIGN="RIGHT"
VALIGN="TOP"
>--<SPAN
CLASS="ATTRIBUTION"
>www.zend.com</SPAN
></TD
><TD
WIDTH="10%"
>&nbsp;</TD
></TR
></TABLE
><P
>Zend-Optimizer is a freeware closed source product.
On the same testcode used for the APC-test, there was speed-decrease of about 5% compared to PHP without
APC.</P
><P
>You have to make your own test, to see, if you have some improvements with your own code.
Be sure not to NOT use <SPAN
CLASS="APPLICATION"
>Zend Optimizer</SPAN
> together with <SPAN
CLASS="APPLICATION"
>APC</SPAN
>,
or your whole setup will not work.</P
></DIV
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="AEN821"
></A
>7.2.2. Download the binary</H3
><P
>Origin-Site: <A
HREF="https://www.zend.com/store/free_download.php?pid=13"
TARGET="_top"
>https://www.zend.com/store/free_download.php?pid=13</A
></P
><DIV
CLASS="TIP"
><P
></P
><TABLE
CLASS="TIP"
WIDTH="100%"
BORDER="0"
><TR
><TD
WIDTH="25"
ALIGN="CENTER"
VALIGN="TOP"
><IMG
SRC="../images/tip.gif"
HSPACE="5"
ALT="Tip"></TD
><TH
ALIGN="LEFT"
VALIGN="CENTER"
><B
>Register at zend.com</B
></TH
></TR
><TR
><TD
>&nbsp;</TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>You have to register yourself at zend.com to get access to the download-page</P
></TD
></TR
></TABLE
></DIV
></DIV
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="AEN828"
></A
>7.2.3. Installing</H3
><P
>There is noting to build, this product is closed-source and so only available as binary for different
platforms. The filename varies according your platform, the sample is for Linux on IA32.</P
><TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>cd /usr/local
tar -xvzf ZendOptimizer-2.1.0-Linux_glibc21-i386.tar.gz
cd ZendOptimizer-2.1.0-Linux_glibc21-i386
./install.sh</PRE
></FONT
></TD
></TR
></TABLE
><P
>The install script is self-explanatory, if you compiled Apache and PHP like described in this document, you can just press
<B
CLASS="KEYCAP"
>ENTER</B
> on all questions about the pathnames.</P
></DIV
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="php.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="tomcat.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>mod_php and its prerequisites</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>&nbsp;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Jakarta Tomcat</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>