Best way to install PHP 5.3 alongside MacPorts PHP 5.2
Ryan Schmidt
ryandesign at macports.org
Thu Dec 13 15:12:41 PST 2007
On Dec 13, 2007, at 16:08, Michael J. I. Jackson wrote:
> Can anybody tell me the best way to install PHP 5.3 (currently in
> development) alongside a MacPorts install of PHP 5.2 on Apache?
There is a php5-devel port which is currently at an earlier version
(5.2.5RC2) than the php5 port (5.2.5) but it could possibly be
updated to 5.3. I'm not sure if you can install php5-devel
simultaneously with the php5 port, but if not, we could look into
making it possible... But Jyrki may want to keep it for PHP 5.2.x
release candidates. In which case, you may have to keep manually
compiling as below.
> I'm having two problems in particular.
>
> 1) I tried downloading and installing the PHP 5.3 snapshot to /usr/
> local using the following ./configure:
>
> ./configure --prefix=/usr/local --enable-calendar --with-iconv=/opt/
> local --enable-exif --enable-ftp --enable-wddx --with-zlib=/opt/
> local --with-libxml-dir=/opt/local --with-gettext=/opt/local --with-
> xml --with-expat-dir=/opt/local --with-xmlrpc --enable-soap --
> enable-filepro --enable-bcmath --enable-trans-sid --enable-mbstring
> --enable-dbx --enable-dba --with-openssl=/opt/local --with-mhash=/
> opt/local --with-mcrypt=/opt/local --with-xsl=/opt/local --with-
> curl=/opt/local --with-pcre-regex=/opt/local --with-gd --with-jpeg-
> dir=/opt/local --with-png-dir=/opt/local --enable-gd-native-ttf --
> without-pear --with-freetype-dir=/opt/local --with-ldap=/usr --with-
> kerberos=/usr --with-iodbc=/usr --with-apxs2=/opt/local/apache2/bin/
> apxs --with-mysql=/opt/local/var/macports/build/
> _opt_local_var_macports_sources_rsync.macports.org_release_ports_www_p
> hp5/work/mysql5 --with-pdo-mysql=/opt/local/bin/mysql_config5 --
> with-mysql-sock=/opt/local/var/run/mysql5/mysqld.sock --with-
> mysqli=/opt/local/bin/mysql_config5 --with-sqlite --with-pdo-
> sqlite=/opt/local --enable-sqlite-utf8
>
> This is basically the same ./configure my MacPorts install uses,
> but with a different prefix. However, I get the following error
> during configure:
>
> checking for specified location of the MySQL UNIX socket... /opt/
> local/var/run/mysql5/mysqld.sock
> checking for MySQL UNIX socket location... /opt/local/var/run/
> mysql5/mysqld.sock
> configure: error: Cannot find MySQL header files under /opt/local/
> var/macports/build/
> _opt_local_var_macports_sources_rsync.macports.org_release_ports_www_p
> hp5/work/mysql5.
> Note that the MySQL client library is not bundled anymore!
>
> So when I take out --with-mysql, it compiles and installs fine, but
> I don't have the MySQL library.
Read the post-extract section of the mysql5 variant of the php5
portfile to see how it copes with this. You just have to make a
couple symlinks to make the layout match what php expects. You could:
cd /tmp
mkdir php5mysql5
ln -s /opt/local/lib/mysql5 php5mysql5/lib
ln -s /opt/local/include/mysql5 php5mysql5/include
Then use --with-mysql=/tmp/php5mysql5 in your php configure line
instead. Then delete /tmp/php5mysql5 when you're done.
> 2) Using the above method, the new Apache module overwrites the old
> module (/opt/local/apache2/modules/libphp5.so). This is just fine
> for running just 5.3, but I don't want to use it all the time! I
> only want 5.3 as a development version. Any help? Is there any way
> that I can install 5.3 so that I can just put a different extension
> on files that I'd like to use it for? .php53 maybe?
Apache cannot support multiple php modules simultaneously. But you
may want to look into using the lighttpd web server with php accessed
through fastcgi instead. I have in the past successfully had php4 and
php5 running simultaneously under lighttpd. Assuming the php5 and
php5-devel ports can be installed simultaneously (which again I'm not
sure of) -- or if you build php 5.3 manually -- you should be able to
get php 5.2 and 5.3 side by side as well. Here's an example from my
lighttpd configuration file, which says to use php5 for all .php
files, except if the URL contains "/php4/" in which case use php4 for
all .php files. You could easily have it react to a different
filename extension instead if you prefer. As you see lighttpd's
configuration is quite different from Apache's and allows for some
very interesting things, like this.
fastcgi.server = (".php" =>
("localhost" =>
(
"socket" => "/tmp/lighttpd-" + var.datetime + "-php5-" + var.PID,
"bin-path" => "/opt/local/bin/php-cgi",
"broken-scriptfilename" => "enable",
"allow-x-send-file" => "enable",
"min-procs" => 2,
"max-procs" => 2,
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "4",
"PHP_FCGI_MAX_REQUESTS" => "500"
)
)
)
)
$HTTP["url"] =~ "/php4/" {
fastcgi.server = (".php" =>
("localhost" =>
(
"socket" => "/tmp/lighttpd-" + var.datetime + "-php4-" + var.PID,
"bin-path" => "/opt/local/bin/php4-cgi",
"broken-scriptfilename" => "enable",
"allow-x-send-file" => "enable",
"min-procs" => 2,
"max-procs" => 2,
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "4",
"PHP_FCGI_MAX_REQUESTS" => "500"
)
)
)
)
}
More information about the macports-users
mailing list