Re: 'God' has spoken... :-)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sebastian wrote:
> so i am 'afraid' of going with php5 in fear it will break my website.

It's rather trivial to test it.  Set up a second Apache server with php5
loaded that listens to port 81 or some other port and point it at the
same document_root.  Then you can switch back and forth by just changing
the port number in the URL.

Or, if you, or your application, doesn't like having :81 in the url
everywhere, you can set up a VirtualHost on your port 80 server just
like you set up virtualhosts for anything else and in it add a ProxyPass
to port 81.  Like this:

<VirtualHost *>
ServerName name1.yourdomain.com
DocumentRoot /var/www/html
... other standard config lines...
</VirtualHost>

<VirtualHost *>
ServerName name2.yourdomain.com
DocumentRoot /var/www/html
ProxyPass / http://name2.yourdomain.com:81/
</VirtualHost>

In your httpd81.conf or whatever you call it you have your regular
VirtualHost block for the name2.yourdomain.com.  The only real
difference is that at the top you have a "Listen 81" line instead of
"Listen 80".

So now you can point your browser at http://name1.yourdomain.com and you
get the PHP4 version of your site and if you go to
http://name2.yourdomain.com you get the PHP5 version.

I typically run at least 2 versions of PHP on my main server, sometimes
more.  You have to fiddle a bit with whatever mechanism you use to start
and stop your server so it will start and stop the different versions.
I tend to just cheat and copy my /etc/init.d/apache to
/etc/init.d/apache81 and edit it appropriately changing the name of the
conf file and the pid file.  So I can start and stop the different
versions manually.

Building multiple versions of PHP isn't very hard either.  The only real
trick is to use the --prefix configure flag.  Something like
--prefix=/usr/local/php5.  Then when you "make install" it will not
overwrite any of your PHP4 stuff, with the one exception that it will
try to modify your main httpd.conf by adding a LoadModule mod_php5.c
/usr/libexec/apache/libphp5.so (or some similar path).  Just go abd get
rid of that line after your make install and move it to the httpd81.conf
file.  Also remember to add something like:
--with-config-file-path=/etc/php5
So you can have separate php.ini files.

Someone also mentioned the lack of decent opcode acceleration for PHP5.
 pecl/apc has come a long way over the last couple of months.  Give it a
try.  I'd love to get some more feedback on it.  To install it:

pear install apc

Will work if you are lucky.  I tend to prefer doing it a bit more manually:

cvs -d:pserver:cvsread@xxxxxxxxxxx:/repository login
password: phpfi
cvs -d:pserver:cvsread@xxxxxxxxxxx:/repository co pecl/apc

cd pecl/apc
phpize
./configure --enable-apc-mmap --with-apxs
--with-php-config=/usr/local/php5/bin/php-config
make install

Then add this to you /etc/php5/php.ini file:

extension=apc.so
apc.enabled=1
apc.shm_segments=1
apc.optimization=0
apc.shm_size=32
apc.num_files_hint=1000
apc.mmap_file_mask=/tmp/apc.XXXXXX

Obviously you can do a "make clean" and run ./configure again but this
time point it at your php4 php-config file and build yourself an apc.so
that you can use for your PHP 4 setup as well.  Then copy the apc.php
script that is included to your document_root and point your browser at
it.  You may want to password protect it.  Or edit the top of the script
where you can set a password.  You will end up with something that looks
like this:  http://buzz.progphp.com/apc.php

I don't really do Windows, but most of this will work on Windows as well
(I think).  You can find APC builds for Windows on http://snaps.php.net.
 But save yourself some headaches and grab a spare PC and install Linux
(I prefer Debian, but it is a hassle to install for newcomers, the
Ubuntu installer makes life easier), FreeBSD, or heck even the newly
available OpenSolaris-x86 (I need to do that soon so I can play with the
ultra-cool DTrace they have).

Long rambling email, but hopefully it will inspire a few people to go
push the edges a bit.  Don't forget to report any bugs you find.  For
APC bugs, report them here: http://pecl.php.net/bugs/report.php?package=APC
For APC docs, see the INSTALL file in the source, or go to:
http://livedocs.phpdoc.info/index.php?l=en&q=ref.apc
Which is mostly the same thing webified.

-Rasmus

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux