Carlow's picture

Hello All,

 

First post here and new the Linux world.

 

I am running WordPress with PHP5.6, can anyone please tell me how to upgrade to PHP7.0 ?

Thanks

C

Forum: 
Jeremy Davis's picture

Our next version of TurnKey is running way behind schedule, but we've been super busy behind the scenes working on it... That will ship with PHP7.0. Once we've released it, then you''ll be able to use TKLBAM to migrate your data to the new release.

As under the hood, TurnKey is Debian, you could do a dist-upgrade to the current Debian stable (aka Stretch/9). And as I say, that has PHP7.0. Although currently we don't have any Stretch packages published in our repo, so it's likely that something will break during that process.

Another option is to install PHP7.0 from a third party repo. That may have security implications though (depending where you install from). And I imagine you will lose the PHP auto security updates, so you'd need to manually keep an eye out for updates and manually install them when they come out (and hope WordPress is compatible with them).

So unless you have a really good reason (i.e. something is actually broken on PHP5.6, or something explicitly needs PHP7.0) then I recommend you wait.

Stuart Grifenhagen's picture

any ideas on when the next version with php 7.x will be released?

 

Thanks...

----

When all is said and done, more will be said, than done!

Jeremy Davis's picture

Sorry if that sounds vague and perhaps a little rude. I don't mean it to come across that way. It's just that there are so many moving parts and things never seem to go according to plan, so it's really hard to estimate. And as we always seem to underestimate the remaining work, providing a concrete date is highly likely to produce disappointment.

If I'd given my best guess in September last year, I would have said by the end of last year, but we're clearly not there yet...

My desire would be yesterday (or actually, last year)! We still have a few core issues we need to resolve which are blocking release. At this point I'm pretty sure we should have them resolved by the end of the week (fingers crossed).

So I'm hopeful that we may have our base appliance (Core) released as an RC (release candidate) late next week. I.e. it should be a fully working v15.0 ISO of Core, but requiring some more testing prior to a "final"/"stable" release.

Once we release that, I'll post on the blog about it, and the more people who assist us with testing, the sooner we'll be able to release a stable version. All the other appliances will be released after that, as soon as they are ready. At this point, it's likely that most (if not all) of the library will be ready for release as soon as stable Core is complete.

Marc Seelinger's picture

My woo commerce install is really pushing me to PHP 7.  Any updates as to the progress of being able to use PHP 7 with TurnKey?
Jeremy Davis's picture

So we're still at least a few weeks away from our updated release.

In the meantime, I can give you a hint on how you could upgrade to PHP7.0 (or 7.1/7.2 if you'd prefer).

As previously noted, for our next major release, PHP7.0 will be the default. But a number of our existing library of appliances are still not compatible with PHP7.0+. So we've needed to investigate how we can support PHP5.6 for those particular appliances.

As it turns out, one of the Debian (and Ubuntu) Developers is one of the lead PHP and Apache packagers. Ondřej Surý also packages various versions of PHP built for Debian (and Ubuntu - but that doesn't concern us) in his own third party repo. The packages included 5.6 for Debian Stretch (which we'll use for the v15.0 appliances that require it). It also packages 7.0/7.1/7.2 for Debian Jessie (the basis of TurnKey v14.x).

To enable PHP7.0 on your current v14.x server, these instructions should do the trick (please note that for AWS Marketplace servers, all these commands will need to be prefaced by sudo):

apt-get update
apt-get install -f apt-transport-https lsb-release ca-certificates
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ jessie main" > /etc/apt/sources.list.d/php.list
apt update
apt install php7.0
Assuming that all goes smoothly, you should now be running PHP7.1. To check:
php -v
If the package update doesn't automatically take care of it, you may also need to restart Apache to ensure that it too is using the new PHP version:
service apache2 restart

Please note, that while we believe Ondřej to be highly trustworthy and have done some of our own vetting (prior to considering including his PHP5.6 in our v15.0 builds), be aware that this is a third party repo. It therefore doesn't have the same level of oversight by others that the default Debian repos do.

It also doesn't provide security updates in the same way that Debian does. Ondřej has assured us that he will continue to provide "best effort" support and timely updates (inc security patches) as long as he can. But he will be stopping support for PHP versions once upstream (i.e. PHP developers) end their support. So in the not too distant future, PHP7.0 may well be removed. When that happens, you'd be advised to migrate your data to a new v15.0 appliance (which will include PHP7.0). Then you can get back the auto security updates that Debian provide (via our default settings). You will likely need to remove some of the config you added above, but I'm happy to assist you with that when you get to that point.

Another alternative, would be to update to a newer PHP version (e.g. 7.1) and remove 7.0.

Either way, it's also worth noting, that once you enable Ondřej's repo, that you will no longer get automatic PHP security updates. You will need to regularly manually check for updates and install them as need be.

Hope that helps and please keep an eye on our blog for upcoming v15.0 release announcements.

Francesco Di Cencio's picture

Hello, thanks to your trick I have upgraded php to version 7.0.30 from 5.6.33 and I can see it from the command php -v. In wordpress, specifically in the plugin gravity pdf I find yet the version 5.6.33... and I find the directive to php5 also in php configuration in webmin and the symlink in /etc/apache2/mods-enabled. I have just restarted apache several times. Why?  How can I do to force apache to use the newer version? Is it possible, in a multiple site environment, to use different php version in different sites?   Thanks a lot, Francesco Di Cencio
Jeremy Davis's picture

Deep apologies on the delay publishing and responding to your comment. I missed it in a flood of spam we had around the time you posted and only just noticed it now...

TBH, I'm not 100% sure, so I'd highly recommend that you make sure you have a (tested and confirmed working) backup before you try any of my suggestions.

First thing would be to make sure that you have the php7.0 Apache mod_php module installed and enabled. AFAIK you can have it installed alongside php5 and it shouldn't cause any issues. Having said that, if you have no need for it, it's possibly better to disable it. The package should be called 'libapache2-mod-php'. The default one is probably called 'libapache2-mod-php5' and the new is probably one called 'libapache2-mod-php7.0'. If it is installed and php7.0 is running as your default PHP, then perhaps just disabling it and reenabling it will resolve your issue? I.e.

a2dismod php5
a2enmod php7.0

[Just updated the above commands to what I think they should be. Hopefully I'm right...]

Regarding Webmin showing the old PHP ini. TBH, I'm not so sure about that. Perhaps there is some way to configure Webmin to show the new one instead? If you're not using the old PHP5, then perhaps you could try is removing the default PHP? Make sure you have a backup though as there is a chance something might break!

Francesco Di Cencio's picture

Thank you Jeremy, I found some modules to install and a plugin (an SSL rewriter) to disable prior in php 5 and reenable in php7. Now it works! I have just a problel with gravity pdf plugin.. because in TK it has a 60 sec. lag before generating the pdf... instead, the same site installed in a cloud provider all works well! I haven't found any issue in any log... I think of some permission problem... What do you think about?   Thanks a lot, Francesco
Marc Seelinger's picture

The steps you outlined above worked like a charm!  Thank you very much!
Marc Seelinger's picture

Could you point me in the direction as to how to check for the php updates and install them?  I will upgrade to v15 as soon as it is ready, but in the meantime I need manually maintain the site.
Jeremy Davis's picture

There isn't actually a super simple way to just update particular packages. But as a general rule, if you run:
apt-get update
apt-get upgrade
You should be good. However, please note that that will install all updates, including those from Debian. As a general rule, that should be fine.

Having said that, personally, I prefer not to do any updates on a production server, except of course security updates. So to facilitate that, I suggest creating yourself a script to make it easy. This should do the job:

cat > /usr/local/bin/update-php <<"EOF"
#!/bin/bash -e
src_file=/etc/apt/sources.list.d/php.list

# options to ensure that only the specific source file is used
opts="-o Dir::Etc::sourcelist=$src_file -o Dir::Etc::sourceparts='-'"

# don't do heuristic list cleanup
update_opts="${opts} -o APT::Get::List-Cleanup='0'" 

# show packages to be upgraded
upgrade_opts="-o APT::Get::Show-Upgraded=true ${opts}"

apt-get update $update_opts
apt-get upgrade $upgrade_opts
EOF
chmod +x /usr/local/bin/update-php

Now you should be able to simply run 'update-php' from the commandline and it should only install updates from the PHP third party repo. I haven't extensively tested it, but hopefully I haven't made any mistakes.

If you want to double check after running, you could try the following and look for php package updates.

apt-get update
apt-get -u upgrade --assume-no | grep php
That should show you a list of packages which would be upgraded if you ran 'apt-get upgrade', highlighting any PHP ones in red (only the letters php will be red). If you get nothing returned, you should be good. If you see any php packages listed there at any point, please let me know.

You could automate that running the script if you wanted, but personally I'd rather run the updates manually unless I really trust the source. That way if there are any issues, I can resolve them then and there. I have no reason to believe that Ondrej's packages will cause any issues, but I'm inclined to suggest caution. Which incidentally is why we only automatically install security updates by default.

Chris Whorton's picture

Running TK WP 15 appliance and trying to upgrade PHP to 7.1. Is this avail?

Trying to run plugin that needs php_ldap.dll php_mbstring.dll php_openssl.dll which are not loaded and need to loaded.  I enabled them in PHP config but not sure how to load them.

 

Thanks for your help.

Jeremy Davis's picture

Hi Chris.

First up, you note that you need 3 dlls?! DLLs (Dynamically Linked Libraries) are Windows files and won't work on Linux. The Linux equivalent are called "shared object" (.so) files. If you explicitly require the DLLs, then perhaps the plugin is Windows only? Or perhaps they have a separate Linux version?

It's also worth noting that all versions of PHP should be compiled against OpenSSL, so for you to explicitly note that, suggests that perhaps things are not as they should be and perhaps this module is not compatible with Linux...?!

If you could please share a little more about which version of TurnKey you are on and what you've done already (it sounds like you may have already updated PHP to 7.1?!) and I'd be more than happy to help you out.

Also it's probably best to start a new thread, rather than piggy back off this old one. I'll see it and respond there.

It's perhaps also worth noting a couple of other threads where newer versions of PHP have been discussed; namely here and here. They both explicitly discuss PHP7.2, but the general gist remains the same so perhaps they might include content of value to you? If you do wish to upgrade PHP version then I'd suggest PHP7.2 as a minimum (7.1 is almost EOL too and third parties other than Debian likely won't maintain it). FWIW, the upcoming v16.0 release of TurnKey (not ETA yet but ASAP) will include PHP7.3 OOTB.

PS I've just adjusted your user account too, so that you should now be able to bypass the spam filters (which can be a little aggressive at times...)

Chris Whorton's picture

Jeremy,

Thanks for the quick response. Downloaded the new version of TK WP ver 15 VMWare Appliance which comes with PHP version 7 (need version 7.1 or better to run the LDAP plugin NADI (Next Active Directory Integration) plugin).

Installed All-In-One Wordpress Migration plugin and restored all of my INTRANET site to the new install appliance.

webmin in to change the php config to enable php_ldap.dll php_mbstring.dll and php_openssl.dll which is required to run NADI.

Rebooted appliance to no avail.(simply enabling the dll's did not enable them after reboot).

SSH into root of appliance and ran the apt-get update and upgrade.

ran  php -v to check
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/php_ldap.dll' - /usr/lib/php/20151012/php_ldap.dll: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/php_mbstring.dll' - /usr/lib/php/20151012/php_mbstring.dll: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/php_openssl.dll' - /usr/lib/php/20151012/php_openssl.dll: cannot open shared object file: No such file or directory in Unknown on line 0
PHP 7.0.33-0+deb9u3 (cli) (built: Mar  8 2019 10:01:24) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.33-0+deb9u3, Copyright (c) 1999-2017, by Zend Technologies

even tried to run apt install 7.2 but the files were not avail for update.

That is where i am.

Thanks

Chris

Jeremy Davis's picture

As noted in my first paragraph, DDLs are Windows only! ;) So that bit will never work... If it explicitly requires DDLs, then it's possibly Windows only or you've downloaded the wrong version.

Another thought is that if you previously had it running on Windows (you mention "INTRANET site") then perhaps the backup needs some manual adjustment or intervention as well?

If you meant the .so files (Linux equivalent of DLL) then FWIW PHP in Debian is compiled against OpenSSL so nothing should be required there.

For the other 2 requirements, if you install the packages that contain those PHP modules, then they should be auto-enabled. I.e.:

apt update
apt install php-ldap php-mbstring

If you need PHP7.1 explictly (TurnKey v15.x comes with PHP7.0), then you'll need to install it via 3rd party repo (as discussed in the links I posted before). If you go that way, then you also need to update the package names that I posted above (to php7.1-ldap php7.1-mbstring) and install some additional packages. You'll at least need:

php7.1-mysql
libapache2-mod-php7.1
php7.1-cli
php7.1-curl
php7.1-gd
php7.1-gettext

There may be additional requirements too, but hopefully googling any Wordpress errors should assist.

Once you've followed those steps (and read through those posts that I linked to) and you're still having issues, perhaps I've overlooked something? Please post back with as much info as possible and I'll be back in touch ASAP.

Add new comment