220 lines
13 KiB
HTML
220 lines
13 KiB
HTML
|
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Part I - Installing PHP4</title><link rel="stylesheet" type="text/css" href="manual.css"><meta name="generator" content="DocBook XSL Stylesheets V1.76.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="apj.html" title="Appendix J. Setting up PHP5 in parallel with PHP4 in SuSE 10.1"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Part I - Installing PHP4</th></tr><tr><td width="20%" align="left"> </td><th width="60%" align="center">Appendix J. Setting up PHP5 in parallel with PHP4 in SuSE 10.1</th><td width="20%" align="right"> </td></tr></table><hr></div><div class="section" title="Part I - Installing PHP4"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2654589"></a>Part I - Installing PHP4</h2></div></div></div>
|
|||
|
|
|||
|
<div class="section" title="Step one; Compiling PHP4 as a module for Apache2"><div class="titlepage"><div><div><h3 class="title"><a name="id2654605"></a>Step one; Compiling PHP4 as a module for Apache2</h3></div></div></div>
|
|||
|
|
|||
|
<p>First download the latest PHP4 tar-ball from php.net or the closest mirror and
|
|||
|
unpack it in a temporary directory. </p>
|
|||
|
<p>Since we will compile PHP4 ourself we need first to make sure a number of
|
|||
|
libraries and the corresponding header files are installed in the system in order to
|
|||
|
be able to compile PHP4. This is done by installing a number of "*-devel.rpm" on
|
|||
|
your server. Depending your wanted configuration different development libraries
|
|||
|
must be made available. </p>
|
|||
|
<p>At the very minimum you will need the "apache2-devel.rpm" which provides the
|
|||
|
"/sbin/apxs2" (Apache eXtenSion 2) command used to build modules with Apache2. Other
|
|||
|
modules you might need are </p>
|
|||
|
<p>
|
|||
|
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
|
|||
|
<p>jpeg-devel.rpm </p>
|
|||
|
</li><li class="listitem">
|
|||
|
<p>png-devel.rpm </p>
|
|||
|
</li><li class="listitem">
|
|||
|
<p>mm-devel.rpm </p>
|
|||
|
</li><li class="listitem">
|
|||
|
<p>xml2-devel.rpm </p>
|
|||
|
</li><li class="listitem">
|
|||
|
<p>mysql-devel.rpm </p>
|
|||
|
</li><li class="listitem">
|
|||
|
<p>...</p>
|
|||
|
</li></ul></div><p>
|
|||
|
</p>
|
|||
|
<p>Before you compile PHP4 you need to configure it by running the "./configure"
|
|||
|
command with the options you want to be included in PHP4. </p>
|
|||
|
<p>We use a small shell script called "mkphp4-sapi" to avoid having to re-type all
|
|||
|
the options each time we compile a new version of PHP. The options we use for a
|
|||
|
typical development server are (you might want to use other options) </p>
|
|||
|
<p>
|
|||
|
</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
|
|||
|
2
|
|||
|
3
|
|||
|
4
|
|||
|
5
|
|||
|
6
|
|||
|
7
|
|||
|
8
|
|||
|
9
|
|||
|
10
|
|||
|
11
|
|||
|
12
|
|||
|
13
|
|||
|
14
|
|||
|
15
|
|||
|
16
|
|||
|
17
|
|||
|
18
|
|||
|
19
|
|||
|
20
|
|||
|
21
|
|||
|
22
|
|||
|
23
|
|||
|
24
|
|||
|
25
|
|||
|
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">#! /bin/sh
|
|||
|
./configure --prefix=/usr/share \
|
|||
|
--datadir=/usr/share/php4 \
|
|||
|
--with-apxs2=/usr/sbin/apxs2 \
|
|||
|
--libdir=/usr/share \
|
|||
|
--includedir=/usr/include \
|
|||
|
--bindir=/usr/bin \
|
|||
|
--with-config-file-path=/etc/php4/apache2 \
|
|||
|
--enable-mbstring --enable-mbregex \
|
|||
|
--with-mysql \
|
|||
|
--with-gd --enable-gd-imgstrttf --enable-gd-native-ttf \
|
|||
|
--with-zlib-dir=/usr/lib \
|
|||
|
--with-png-dir=/usr/lib \
|
|||
|
--with-jpeg-dir=/usr/lib --with-xpm-dir=/usr/X11R6 \
|
|||
|
--with-tiff-dir=/usr/lib --with-ttf-dir=/usr/lib \
|
|||
|
--with-freetype-dir=/usr/lib \
|
|||
|
--enable-ftp \
|
|||
|
--enable-memory-limit --enable-safe-mode \
|
|||
|
--bindir=/usr/bin \
|
|||
|
--enable-bcmath -enable-calendar \
|
|||
|
--enable-ctype --with-ftp \
|
|||
|
--enable-magic-quotes \
|
|||
|
--enable-inline-optimization \
|
|||
|
--with-bz2 \
|
|||
|
--with-iconv</span></pre></td></tr></table></div><p>
|
|||
|
</p>
|
|||
|
<p>However there are one thing You should take notice of. We have specified the
|
|||
|
config file path (where the php.ini resides) to "/etc/php4/apache2/" as You can
|
|||
|
probably guess from this naming convention it will make it possible to have
|
|||
|
different ini files for both PHP4 and PHP5. In fact we have four different ini files
|
|||
|
according to </p>
|
|||
|
<p>
|
|||
|
</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
|
|||
|
<p>"<code class="filename">/etc/php4/apache2/php.ini</code>" Used by the apache
|
|||
|
SAPI module version of PHP4 </p>
|
|||
|
</li><li class="listitem">
|
|||
|
<p>"<code class="filename">/etc/php4/cli/php.ini</code>" Used by the standalone
|
|||
|
client version of PHP4 (/usr/bin/php4) </p>
|
|||
|
</li><li class="listitem">
|
|||
|
<p>"<code class="filename">/etc/php5/apache2/php.ini</code>" Used by the apache
|
|||
|
CGI version of PHP5 </p>
|
|||
|
</li><li class="listitem">
|
|||
|
<p>"<code class="filename">/etc/php5/cli/php.ini</code>" Used by the standalone
|
|||
|
client version of PHP5 (/usr/bin/php5) </p>
|
|||
|
</li></ol></div><p>
|
|||
|
</p>
|
|||
|
<p>When you run this you might get some errors saying that the configuration file
|
|||
|
cannot find some library. This is a sign that you might have the library installed
|
|||
|
but not yet have the "*-devel" RPM version added to your system which is needed
|
|||
|
since this is where all the usual header files needed for compilation would be. </p>
|
|||
|
<p>So for example if you get an error like "Cannot find PNG libraries. Please check
|
|||
|
your that the corresponding "png-devel" library is installed and if not go back to
|
|||
|
Yast2 and install the needed "*-devel.rpm" versions of the libraries. </p>
|
|||
|
<p>When You have been able to successfully run the ./configuration command it is time
|
|||
|
to compile. Type "make" as usual but do not type "make install", now wait until the
|
|||
|
compilation finishes. </p>
|
|||
|
<p>
|
|||
|
</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3>
|
|||
|
<p>If you are on a Pentium4 HT or on a real dual CPU machine you can speed up
|
|||
|
the compilation by instead giving the "make -j3" command which will start up
|
|||
|
3 concurrent compilation processes.</p>
|
|||
|
</div><p>
|
|||
|
</p>
|
|||
|
<p>Again; Do not run "<code class="code">make install</code>" since this will try to modify the
|
|||
|
configuration files in a way that isn't SuSE friendly. </p>
|
|||
|
<p>The resulting PHP4 that you have built can be found in
|
|||
|
"<code class="filename">.libs/libphp4.so</code>". Now we only want to copy this file to
|
|||
|
the location of the other Apache2 modules. </p>
|
|||
|
<p>
|
|||
|
</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3>
|
|||
|
<p>Again, PHP is only guaranteed to work with the non-threaded version of
|
|||
|
Apache2, which means that you should have installed the "apache2-prefork"
|
|||
|
MPM and NOT the "apache2-worker" MPM. </p>
|
|||
|
</div><p>
|
|||
|
</p>
|
|||
|
<p>If you have correctly installed the prefork MPM several existing modules should
|
|||
|
now be installed in "<code class="filename">/usr/lib/apache2-prefork/</code>". </p>
|
|||
|
<p>So the only thing that now remains is to copy
|
|||
|
"<code class="filename">.libs/libphp4.so</code>" to
|
|||
|
"<code class="filename">/usr/apache2-prefork/</code>" in order for Apache to find PHP4 as
|
|||
|
a module. </p>
|
|||
|
</div>
|
|||
|
<div class="section" title="Step two; Enable the PHP4 module in the Apache2 configuration"><div class="titlepage"><div><div><h3 class="title"><a name="id2654607"></a>Step two; Enable the PHP4 module in the Apache2 configuration</h3></div></div></div>
|
|||
|
|
|||
|
<p>There are three steps to needed to enable PHP4 in Apache. </p>
|
|||
|
<p>
|
|||
|
</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
|
|||
|
<p>Add php4 to the APACHE_MODULE string in "/etc/sysconfig/apache2" in
|
|||
|
order so that the startup script in SuSE will add the appropriate
|
|||
|
LoadModule statement so that Apache will load PHP4 as a module. In our
|
|||
|
case our module string will look like </p>
|
|||
|
<p>
|
|||
|
</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
|
|||
|
2
|
|||
|
3
|
|||
|
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">APACHE_MODULES="access actions alias auth auth_dbm autoindex cgi \
|
|||
|
dir env expires include log_config mime negotiation setenvif ssl \
|
|||
|
suexec userdir dav dav_svn php4 "</span></pre></td></tr></table></div><p>
|
|||
|
</p>
|
|||
|
</li><li class="listitem">
|
|||
|
<p>Telling Apache to run files ending in *.php through the PHP4 module.
|
|||
|
This is done by specifying the MIME type which the PHP4 module
|
|||
|
registered itself with. In addition we also tell Apache to search for
|
|||
|
the appropriate PHP index files in case a directory name is given as the
|
|||
|
URL. We do this by creating a file "<code class="filename">php4.conf</code>" with
|
|||
|
the following content </p>
|
|||
|
<p>
|
|||
|
</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
|
|||
|
2
|
|||
|
3
|
|||
|
4
|
|||
|
5
|
|||
|
6
|
|||
|
7
|
|||
|
8
|
|||
|
9
|
|||
|
10
|
|||
|
11
|
|||
|
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code"><IfModule sapi_apache2.c>
|
|||
|
AddType application/x-httpd-php .php3
|
|||
|
AddType application/x-httpd-php .php4
|
|||
|
AddType application/x-httpd-php .php
|
|||
|
AddType application/x-httpd-php-source .php3s
|
|||
|
AddType application/x-httpd-php-source .php4s
|
|||
|
AddType application/x-httpd-php-source .phps
|
|||
|
DirectoryIndex index.php3
|
|||
|
DirectoryIndex index.php4
|
|||
|
DirectoryIndex index.php
|
|||
|
</IfModule></span></pre></td></tr></table></div><p>
|
|||
|
</p>
|
|||
|
<p>and place it in the "<code class="filename">/etc/apache2/conf.d/</code>"
|
|||
|
directory. This will guarantee that it will be read upon startup. The
|
|||
|
"<code class="code">IfModule</code>" statement in the beginning is just to avoid
|
|||
|
the statements to be executed in case the PHP4 module is not loaded (we
|
|||
|
test this by checking if the "<code class="code">sapi_apache2.c</code>" has been
|
|||
|
activated in Apache). </p>
|
|||
|
</li><li class="listitem">
|
|||
|
<p>The final step now is to restart Apache by doing (as root) </p>
|
|||
|
<p>
|
|||
|
</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
|
|||
|
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">$> /etc/init.d/apache2 restart</span></pre></td></tr></table></div><p>
|
|||
|
</p>
|
|||
|
</li></ol></div><p>
|
|||
|
</p>
|
|||
|
<p>In order to verify that PHP has been enabled run a standard PHP script; for
|
|||
|
example by copying the following script to "<code class="filename">/srv/www/htdocs/</code>" </p>
|
|||
|
<p>
|
|||
|
</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
|
|||
|
2
|
|||
|
3
|
|||
|
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags"><?php</span><span class="hl-code">
|
|||
|
</span><span class="hl-identifier">phpinfo</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code">;
|
|||
|
</span><span class="hl-inlinetags">?></span></pre></td></tr></table></div><p>
|
|||
|
</p>
|
|||
|
<p>and name it as "<code class="filename">phpinfo.php</code>" . If you now go to your favorite
|
|||
|
browser and run this script as "http://localhost/phpinfo.php" you should get the
|
|||
|
standard PHP4 information presented as a quite big table. </p>
|
|||
|
</div>
|
|||
|
</div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"> </td><td width="20%" align="center"><a accesskey="u" href="apj.html">Up</a></td><td width="40%" align="right"> </td></tr><tr><td width="40%" align="left" valign="top"> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> </td></tr></table></div></body></html>
|