How to update PHP NC 19.0.0?

How do i update PHP on my Ubuntu Nextcloud 19.0.0?

security settings is telling me:

Je draait momenteel PHP 7.2.24-0ubuntu0.18.04.6. We adviseren je om, zo gauw je distributie dat biedt, je PHP versie bij te werken voor betere prestaties en beveiliging geleverd door de PHP Group.

Which is in dutch but i think most of you recognize the message. It means i am running PHP 7.2.24 and they advise me to upgrade. I have looked and came across this site:

This tells me to:

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install -y php7.4

Is this correct and is this all i have to do? Should i go for 7.3 or 7.4?

Sounds about right. Go for PHP 7.4, it works great with Nextcloud.

“About right” or totally right? :stuck_out_tongue:

I don’t wanna break my Nextcloud :wink:
(Yes of course i have a backup)

You won’t break your Nextcloud. You can easily install PHP 7.4 beside 7.2. If anything does not work, you can switch back to 7.2. I have 4 instances of Nextcloud running on 7.4 now for some months, no problem.

Since we/me are here to learn :slight_smile: How do i switch back?

You should have a reference to php7.2 in your vhost configuration. That’s how it works with Apache, I don’t know nginx, but should be similar. Just change that.

Have a look here (below). Can replace 7.3 with 7.4…
As long as you run Apache and MariaDB/MySQL it should work even on non-RasPI…

@anon71540698, this is pretty different than what @eehmke is telling me to do. so what is the best way to do this? :slight_smile:

I run the Hansson VM (on an ESX server) by the way, this one:

https://www.hanssonit.se/nextcloud-vm/

I have tried the commands in my startpost, and Nextcloud is still telling me:

Je draait momenteel PHP 7.2.24-0ubuntu0.18.04.6. We adviseren je om, zo gauw je distributie dat biedt, je PHP versie bij te werken voor betere prestaties en beveiliging geleverd door de PHP Group.

Let’s start from scratch. I assume you have command line access. What is the output of this commands:

sudo dpkg -l | grep php
php -v

Do you have apache or nginx installed? If apache, what is the content of directory

/etc/apache2/sites-available

sudo dpkg -l | grep php shows me:

a couple of lines with php7.2… and php7.4…

php -v shows me:

PHP 7.4.6.

the apache2/sites-available directory holds:
000-default.conf
cloud.DOMAIN.conf
cloud.DOMAIN.nl.conf
default-ssl.conf
nextcloud_http_domain_self_signed.conf
nextcloud_ssl_domain_self_signed.conf

So PHP 7.4 is installed. What is the content of

/etc/apache2/sites-enabled

There should be a symlink to one of the files in sites-available. Show us the content of that file.

Only holds:

cloud.DOMAIN.nl.conf

So not the same as sites/availabe…

my nextcloud url is cloud.DOMAIN.nl btw.

Is cloud.DOMAIN.nl.conf an actual file or a symlink? It should be a symlink to sites-available. Anyway please post the content of that file. Remove/replace domain information.

when i enter vi cloud.DOMAIN.nl.conf it shows:

<VirtualHost *:80>
ServerName cloud.DOMAIN.nl
Redirect / https://cloud.DOMAIN.nl

<VirtualHost *:443>

Header add Strict-Transport-Security: "max-age=15768000;includeSubdomains"
SSLEngine on
SSLCompression off
SSLProtocol all -TLSv1 -TLSv1.1 -SSLv2 -SSLv3
SSLCipherSuite ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHEv-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:DES-CBC3-SHA:!DSS
SSLHonorCipherOrder on

YOUR SERVER ADDRESS

ServerAdmin admin@cloud.DOMAIN.nl
ServerName cloud.DOMAIN.nl

SETTINGS

<FilesMatch "\.php$">
    SetHandler "proxy:unix:/run/php/php7.2-fpm.nextcloud.sock|fcgi://localhost"
</FilesMatch>

DocumentRoot /var/www/nextcloud

<Directory /var/www/nextcloud>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
Satisfy Any
</Directory>

<IfModule mod_dav.c>
Dav off
</IfModule>

SetEnv HOME /var/www/nextcloud
SetEnv HTTP_HOME /var/www/nextcloud

# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
<Files ".ht*">
Require all denied
</Files>

# Disable HTTP TRACE method.
TraceEnable off
# Disable HTTP TRACK method.

So you have a handler for php.7.2-fpm:

SetHandler "proxy:unix:/run/php/php7.2-fpm.nextcloud.sock|fcgi://localhost"

So you have to set this up for php7.4, restart the fpm handler, change the line in your cloud.DOMAIN.nl.conf and restart apache.

Tell us if you need help with these steps. They are quite straightforward.

I have changed the 7.2 into an 7.4 (and rebooted) but now when i try to open my cloud the error is:

Service Unavailable

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

(i have edited the file in /etc/apache2/sites-enabled)

This could mean a number of things, but in the end all point to PHP not working properly:

  • is php7.4-fpm running?
  • are all necessary php7.4 packages installed? The database module might be missing (e.g. php7.4-mysql)

Also, (it’s a bit annoying in Debian-based systems) you have to manually port the changes you made to the php7.2 configuration files (in /etc/php/7.2/fpm/... to the 7.4 directory. This e.g. concerns upload size and memory limits.

I wish i hadn’t have to ask…but how do i check if php fpm is running? And how do i check if all necessary packages are installed?

I don’t understand what you mean by port changes, what do i need to do? (Exactly :wink: )

I told you to set up the fpm handler for 7.4 .

There should be a file in

/etc/php/7.2/fpm/pool.d/

that refers to your fpm config. Copy it to

/etc/php/7.4/fpm/pool.d/

and edit it, replace all occurences of 7.2 to 7.4.
next

sudo systemctl restart php7.4-fpm.service

now restart apache. You don’t have to reboot, this is not windows.