ryankr1
By:
ryankr1

How to re-install PHP7 with ZTS enabled on Ubuntu 16.04?

February 5, 2017 433 views
PHP Ubuntu 16.04

I've installed the LAMP distribution on Ubuntu 16.04, and now I want to use threads in PHP7, but it wasn't initially installed with ZTS enabled so now I need to reinstall it. Just wondering if there's a guide to making this happen.

2 Answers

Man this seems like a huge amount of work for something so simple. Would you be able to recommend any other language that I could use for scripting with similar functionality to PHP but with threads already included?

@ryankr1

This can be done and I'm running a test on my mini-guide before posting them so I can troubleshoot before handing them over.

Upfront, this will require rebuilding PHP from source and there are a few warnings that come with it.

WARNINGS

Building from source is resource intensive and may fail on 512MB Droplets. It also takes a long time (20-30 minutes up to 1+ hours depending on resources), so be patient and don't close out your connection.

I highly recommend building your package on a fresh droplet and transferring the package over to your existing. Why? The first command, build-dep is going to install numerous packages that most standard web servers do not need, thus creating more for you to update and manage.

Create a snapshot of your existing Droplet before you install the created package. You will need to uninstall the current before you will be able to install the new. Additionally, creating a backup before you attempt to install the new package means you have a security blanket that'll allow you to restore to previous state, prior to the package being installed.

Lastly, please note that by building your own packages, you are now responsible for updating them. This means that where you previously could simply run apt-get -y upgrade and the latest patches and fixes would be installed if available from the maintainer, you will have to go through the process I detail each time you need to rebuild to include what was updated, etc (i.e. security patches, bug fixes, etc).

I'll follow up shortly.

  • @ryankr1

    Current build is failing on my end. Working to resolve the error, though so far it's throwing very vague errors, which are causing the build to fail.

    That being said, the option to compile from PHP's source is always an option as well. It's a little more detailed and hands-on, but can be done. It just really depends on whether or not you're comfortable compiling PHP each time a new release/patch/fix is released.

    Beyond that, IIRC and from what I've read, the threaded option only works from the CLI, so for threaded PHP scripts to work properly, you'd need to create a script and then run that script from the CLI. This could, of course, be done using system() (PHP's version) from within a web-based PHP script, but I wanted to point that out in case you were not aware.

    Ultimately we'd be compiling this against the CLI version of PHP that is offered by package maintainers.

Have another answer? Share your knowledge.