Installing and Testing PHP Beta (CLI Only)

Last week, the final Beta version of PHP 7.2 was released and next week the first Release Candidate was released.

If you want to test this next version of PHP ahead of time, now is a good time to start. Not only will it prepare your site for when the final release comes out, but also it helps the community to find bugs and fix them early on.

I wanted to upgrade an existing setup and without depending on a third party repository (I am stubborn like that). I managed to get it working in the CLI, but still have some work to do for Apache2. I will make a follow up post when I have managed that.

Step 1 - Install Dependencies

I found that only one dependency was required: libxml. To install it, simply do:

sudo apt-get install libxml2-dev

This was the only dependency that I found I needed for upgrading just the PHP on the CLI. You may find you have more, you will be told what they are when you attempt to install later.

Step 2 - Download PHP

Next, download the desired PHP package onto the server. Stable releases can be found on their website. In this case, I am installing the Beta version which you can find here along with their other pre-release versions of 7.2.

So I used the wget command to fetch the desired package:

wget https://downloads.php.net/~remi/php-7.2.0beta3.tar.gz

Next, unpack it with the next two commands:

gunzip php-7.2.0beta3.tar.gz
tar -xf php-7.2.0beta3.tar

Once unpacked, navigate into the folder.

Step 3 - Configure

The next thing to do is run

./configure

Now in my case, this was enough, at least during this experiment, but you may want to configure with options. To see a list of commands, simply run:

./configure --help

You can see all kinds of options such as enabling or disabling certain features and changing the path where PHP will be installed.

Step 4 - Make and Install

Now you are ready to install. Inside the folder, run:

sudo make && sudo make install

I found the sudo to be pretty important for this step. You probably have time at this stage to go and make yourself a cup of tea whilst it does its magic.

Step 5 - Run Tests

At this point, if you run php -v you should see the version that you have just installed. If you have done different configurations, you may have some work to do in order to make the command available (I won't cover that today).

Before you do anything else, there is one more thing that you can do that is extremely simple by extremely helpful to those who maintain PHP:

make test

Go and make yourself another tea whilst it runs the tests. At the end, you will have to put in your e-mail address and then it will send the results of this command off.

Finished

So thats it. Now there are probably a million things that do not work as this all seemed a little too easy. But it is a start. I will try and see if I can get apache to use this version of PHP rather than the original one and let you know my findings.

Meanwhile, I think I will use one of the repositories that have it pre-built in the future to save myself the headache when it comes to going to production with it!


© 2012-2023