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.
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.