Tuesday, June 24, 2008

Installing PHP6 (For beginners)

Installing PHP6 (For beginners)

Hello all, you might have read that PHP6 is under and has been under development for the past few months. Well after hacking around some code trying to get some DirectoryIterator unicoded and ready for php6, I have ran into the problem of compiling php6.. So I figured, might as well give an idea to anyone who feels like on how to install (compile) php6.

Notice that I will be using the command:

  • su -c "command"

Which is because some system do not have sudoers setup yet (yes it does still exist)

Ok, before reading this, here's a couple usefull links:

http://php.net/
http://php.net/anoncvs.php (Most used here)
http://snaps.php.net/
http://cvs.php.net/
http://site.n.ml.org/info/flex/
http://icu.sourceforge.net/download/3.6.html


Hello all, you might have read that PHP6 is under and has been under development for the past few months. Well after hacking around some code trying to get some DirectoryIterator unicoded and ready for php6, I have ran into the problem of compiling php6.. So I figured, might as well give an idea to anyone who feels like on how to install (compile) php6.


There is also a numerous amount of tools you'll have to install before you might become able to try to compile PHP6.

  • autoconf: 2.13
  • automake: 1.4+
  • libtool: 1.4.x+ (except 1.4.2)
  • bison: 1.28, 1.35, 1.75, 2.0 or higher
  • flex: 2.5.4
  • re2c: 0.9.11+


Of course, all this information can be found on the php's page (http://php.net/anoncvs.php )

Also, the coolest part of this (The heart of php6 imho - else than andrei and sara (joking))) is that package you'll have to install:
http://icu.sourceforge.net/download/3.6.html

You can start by executing the following commans:

  • mkdir ~/development; cd ~/development
  • wget ftp://ftp.software.ibm.com/software/globalization/icu/3.6/icu4c-3_6-src.tgz

+ ^ This is for linux of course

  • tar -xzvf icu4c-3_6-src.tgz
  • cd icu; cd source
  • su -c "mkdir /usr/local/icu"
  • ./configure --prefix=/usr/local/icu && make && make install

^ You might get an error related to zlib (Version to low, I strongly suggest to update it if
you get the error)

So what? You are done with ICU compiling ? Let's move on shall we ?

So before installing php6, you have to download it. You can choose from various places, first
you can simply look at http://snaps.php.net (Which are frequent snapshots of the cvs repository) and get the latest php6 snap or you can simply make an anonymous checkout (for those who dont' have a username here's how to do that)

It is also recommended that you put these configurations into your ~/.cvsrc file:

  • cvs -z3
  • update -d -P
  • checkout -P
  • diff -u


Then you are ready to go for your anonymous cvs checkout

(Username: "cvsread" and password "phpfi")

  • cvs -d :pserver:cvsread@cvs.php.net:/repository login
  • cvs -d :pserver:cvsread@cvs.php.net:/repository checkout php6


The previous commands will execute a cvs checkout (Get the code) and store it into ~/development/php6

Once you have installed all the tools stated above, did your checkout, and all is square here comes the second part.

You'll have to execute the following commands (Using apache2 for this example):

  1. cd php6
  2. ./buildconf
  3. sudo "mkdir /usr/local/php6"
  4. ./configure --prefix=/usr/local/php6 --with-icu-dir=/usr/local/icu --with-apxs2=/usr/bin/apxs2

(Just using apxs2 as an example)
^ You can of course add more options as such as --with-mysql=/usr/bin (if mysql is in bin)
--with-phar --with-bz2. Just see the command "./configure --help" for a list of options.

^ Also, if the make is dying because of some flex problems, you can use the command
"apt-get install flex-old" or simply get the source at: http://site.n.ml.org/download/20030401085856/flex/flex-2.5.4a.tar.gz

  1. then ,if it all went well of course, you type:
  2. make && su -c "make install"

If it all went well, then you should have the php6 files all ready to be used in /usr/local/php6
Just give a look at it to see if you have new directories, etc.

If you used the --with-apxs(2) options, you should already be set with the apache load_modules et all. You might notice that it said LoadModule php5 well don't worry that's all good you'll just need your libphp6.so which is usually well placed when using --with-apxs.

If you are not sure, just look at your /etc/apache2/httpd.conf and /etc/apache2/mods-enabled/php5.load files to see if you have it pointing to libphp6.so (Which it probably is)

So are you ready ? Last command line command:
- su -c "apache2ctl restart"

If you do not get an error, you should be able to go to your web directory
(Here I am using /var/www on my development box) and add a file with this content:

phpinfo();
?>

If you are lucky and it all went well, then you will see "PHP Version 6.0.0-dev" with probably a million warnings. Well it is installed, you can start fiddling around and testing.

Hope this helps a couple people (Even though a lot of you probably gave me hints during this crusade)

No comments: