Yeah, that's what I was thinking. I figured there would be a ppa and packages, but I didn't find any... UPDATE: August 10th, 2015 - there is a PPA now -- you should try it first. https://launchpad.net/~ondrej/+archive/ubuntu/php-7.0
[historical content]... So... with a little help from: http://www.zimuel.it/install-php-7/ , I managed to refine a test process so that it is relatively easy and quick and works with apache.
Before you start... you may want to look at what has been or quickly will be deprecated in php7 and start getting your code in gear. https://wiki.php.net/rfc/remove_deprecated_functionality_in_php7
This is a gross hack. You'd be silly to do this on any production server. Do this on a throw-away VM, just for testing. My recipe below OVERWRITES the system php -- because I wanted a quick and dirty hack to keep as many settings the same as possible. If you don't have the ability to clone a vm or build a new test LAMP stack in a few minutes... do not proceed. You shouldn't be reading any further. Here be dragons!
OK... so you're still with me? You understand this is an EXPERIMENT... good.
Build a test Ubuntu 14.04 LAMP stack.
I'm *ASSUMING* you have some workload already that you want to test with php7 and that you're running Ubuntu 14.04 and your LAMP stack is already running.
All we're going to do is:
- Add missing packages required to build php7 from latest source
- Overwrite php5 with php7
- Disable php5 in apache
- Make existing Apache work with libphp7.so
- restart apache and hope it worked
- do some testing on our own
Add build dependencies for php5 -- this is probably a good idea and MAY pull in most if not all of the packages below.
sudo apt-get build-dep php5
Add missing requisite packages:
sudo apt-get install build-essential libt1-dev bison libbz2-dev libjpeg62-dev libpng12-dev libfreetype6-dev libgmp3-dev libmcrypt-dev libmysqlclient-dev libpspell-dev librecode-dev apache2-dev git
Symlink the gmp.h file into /usr/include/ so the makefile can find it. I tried explicitly specifying the path in configure and it didn't work, so... unless you know why, just make this symlink
ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h
Check out the latest php source code
git clone https://git.php.net/repository/php-src.git
Change into the source directory and run buildconf
Configure php7 source code
NOTE: As of March 4th code, I had to remove the following line from configure above:
NOTE: As of August 6th, I had to remove the following line from the configure above:
Build the code - now would be a good time for a cup of coffee.
Might as well run the tests, I got two errors that seemed safe to ignore out of over 10K tests. I chose not to email the dev list.
** Mar 5th, 2015 - UPDATE - after this code update ... there are a lot of failing tests that will need to be removed. #FIXME This update and removal of the mysql code broke my app on March 5th - looks like we're using ext/mysql - time to dig into code and use mysqli http://www.saotn.org/migrate-php-mysql-mysqli/
Install php7 -AGAIN.... if you type the command below, you're overwriting your php-5.5.9 install and should ubuntu php packages be updated in the future and upgraded, you might be unhappy. We're just trying to do a quick test of php7... remember?
Now... In case your app specificially calls out php5 binary as /usr/bin/php5, let's force php apps to use the new php...
mv php5 php5.orig
mv phpize5 phpize5.orig
mv php-config5 php-config5.orig
ln -s php php5
ln -s phpize phpize5
ln -s php-config php-config5
We need a php7.conf file. Assuming your LAMP stack already worked with php5, path of least resistance is to copy existing one to new name.
cp /etc/apache2/mods-enabled/php5.conf /etc/apache2/mods-enabled/php7.conf
Disable php5 in apache - we can't have php5 and php7 enabled - then restart apache
Create /etc/php7 directory by making a symlink to /etc/php5 - not clear if this is required - I just did it since I'd already hacked up so much of the php install already.
cd /etc/ && ln -s php5 php7
Check to see if this worked..
# php --version
PHP 7.0.0-dev (cli) (built: Mar 4 2015 20:49:17)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0-dev, Copyright (c) 1998-2015 Zend Technologies
From Apache webserver:
tail -200 /var/log/apache2/error.log
[Wed Mar 04 21:28:21.603995 2015] [mpm_prefork:notice] [pid 20692] AH00163: Apache/2.4.7 (Ubuntu) PHP/7.0.0-dev OpenSSL/1.0.1f configured -- resuming normal operations
Success! (or... if not, maybe you need to do some debugging)
You can do whatever you want. I chose to do an application benchmark, some manual QA testing of my app, and I wrote a blog post.
* opcache is now working once I updated the --with-config* statements above.
Just remember - when you're done testing and playing, destroy this test environment before a php package update overwrites everything. This was just for some quick tests, remember?