Cannot upgrade to NC 26 due to PHP 7.4

Are you running it in a VM-Ware, VirtualBox or what?

When you expect some help, you should provide information!

As far as I know, those Virtual Mashines are running on Ubuntu. So you can upgrade the underlying Ubuntu as normal as every Ubuntu Server with the apropriate tools.

Please provide information about the level of your skills. How did you upgrade your server so far?

Itā€™s runnin a VMware virtual machine on VMware Player. Yes itā€™s running Ubuntu as the underlying O/S

When Iā€™ve updated NC In the past, I use the following two commands from the VM console:

Major: sudo bash /var/scripts/update.sh
Minor: sudo bash /var/scripts/update.sh minor

I can follow instructions with Linux, but I donā€™t have a background to what commands I ought to use if they are not listed, etc. If itā€™s easy enough as in type X commands to update I can do. If itā€™s a go update a dependency first and we donā€™t provide instructions for it, then I will likely have issues.

It should be fairly easy to Google something like ā€œubuntu upgrade phpā€ or similar to find the answers you need, no? :slight_smile:

1 Like

I wasnā€™t sure if there was something specific related to NextCloud that I had to be aware of Again my Linux knowledge is limited so I didnā€™t want to just assume it easy, Iā€™d definitely go that route with Windows but I wanted to ask the community if this was about as easy

I wouldnā€™t say so - Nextcloud is ā€œjustā€ a bunch of PHP files. But part of upgrading PHP for Nextcloud is to check that you are upgrading to a PHP version that is supported by both Nextcloud and the apps in Nextcloud that you intend to run (the apps themselves are PHP code too, so they need to support the PHP version). And also, some PHP extensions are needed as well, so these too will be upgraded.

Doesnā€™t VMware Player support snapshots? If I had a VM, Iā€™d take a snapshot of it and then go all in on trying the upgrade, and only when I know everything truly works for a while fine Iā€™d delete the snapshot. If things doesnā€™t work out, just restore the snapshot.

VMware Player doesnā€™t support snapshots, however I do backup the VM folder regularly and can make a new backup prior to upgrading PHP.

I was trying to do a little research on upgrading PHP, although I canā€™t say if the Extensions update automatically or not. I believe the only App I was using that utilized PHP was a Passwords app but Iā€™ve switched out recently to another

That works too. Itā€™s a good idea to shut the VM down entirely (including the OS in it - not just suspending it) first.

Iā€™d just do that and go for it. If you encounter problems you an ask about those specifically when you hit them.

1 Like

Well I guess there is extra config that needs done with NextCloud. I removed PHP7 and installed 8.1 and common dependencies. The console command php -v reported version 8.1.17 installed. But, then my NextCloud instance was entirely unusable, just got a 503 Service Unavailable and couldnā€™t get it up. The VM booted fine, rebooted fine, but removing PHP7 must have altered other files that NC relies on. Rolled back to my backup and the server is good, but is there just a simple upgrade to PHP8 or do I need to fully remove PHP7 first?

@enoch85 What needs to be done to update PHP on the VM?

What kind of php your VM was using? php module or php-fpm?

what is the echo of
ls -l "/etc/apache2/conf-enabled/"

Based on this output, I would assume php-fpm

lrwxrwxrwx 1 root root 30 Feb 27 2022 charset.conf ā†’ ā€¦/conf-available/charset.conf
lrwxrwxrwx 1 root root 44 Feb 27 2022 localized-error-pages.conf ā†’ ā€¦/conf-available/localized-error-pages.conf
lrwxrwxrwx 1 root root 46 Feb 27 2022 other-vhosts-access-log.conf ā†’ ā€¦/conf-available/other-vhosts-access-log.conf
lrwxrwxrwx 1 root root 33 Feb 27 2022 php7.4-fpm.conf ā†’ ā€¦/conf/available/php7.4-fpm.conf
lrwxrwxrwx 1 root root 31 Feb 27 2022 security.conf ā†’ ā€¦/conf-available/security.conf
lrwxrwxrwx 1 root root 36 Feb 27 2022 serve-cgi-bin.conf ā†’ ā€¦/conf-available/serve-cgi-bin.conf

Verry good.

Here you get a Step by Step upgrade procedure of your php:

Step 1

Upgrade your system:

sudo apt-get update && sudo apt-get dist-upgrade

Check if reboot required with this commandline:

[ -f /var/run/reboot-required ] && { echo "Reboot required"; read -p "Press ENTER to reboot or ^C to cancel" dummy; sudo systemctl reboot; exit; } || echo "No reboot required"

Step 2

Install the new php-Packages with this commands:

packages="$(echo $(dpkg -l | awk '/^ii/ {print $2}' | grep -i php7.4 | sed 's/php7\.4/php8.1/g'))"
sudo apt-get install $packages

Step 3

check the configuration files:

You now have two php directories in /etc/php:

/etc/php/7.4
and
/etc/php/8.1

In both directories are two subdirectories that interest us: cli and fpm

Now you have to take over the settings from the 7.4/cli/php.ini and 7.4/fpm/php.ini files into the 8.1 Versions.

If some variables are removed in the new Version, it may be, that those are removed from the new php-version.

Specially this vallues you should look for:

max_execution_time
max_input_time
memory_limit
post_max_size
include_path
sys_temp_dir
upload_tmp_dir
upload_max_filesize
max_file_uploads
default_socket_timeout
opcache.enable
opcache.enable_cli

and if your Nextcloud uses redis:

redis.session.locking_enabled=1
redis.session.lock_retries=-1
redis.session.lock_wait_time=10000

Now you should take a look into the file /etc/php/7.4/fpm/pool.d/www.conf
and take over this settings into the new (8.1) Version:

pm.max_children
pm.start_servers
pm.min_spare_servers
pm.max_spare_servers
pm.max_requests

Step 4

Now deaktivate the old php7.4-fpm and activate the new php8.1-fpm with this commands:

sudo a2disconf php7.4-fpm
sudo a2enconf php8.1-fpm
sudo systemctl reload apache2

Step 5

Check if your Nextcloud is running as expected.

Step 6

Remove the old php:

sudo apt-get remove --purge php7.4*

Step 7

Do the Nextcloud Server update:

sudo -u www-data php -f /var/www/nextcloud/occ app:update --all
sudo -u www-data php -f /var/www/nextcloud/updater/updater.phar

Calmly do everything step by step!

Much luck

I think this is an important information for all who read here by chance. The updater of Nextcloud 25 also works with PHP8.2.

Hi,

There are several guides online on how to upgrade PHP in general. You need to keep in mind that we run some PECL dependencies and that itā€™s PHP-FPM with a certain setup, and you need to change the apache config in some places.

We offer support here: https://shop.hanssonit.se/product/upgrade-php-version-including-dependencies/

1 Like

I appreciate everyoneā€™s suggestions, however I wasnā€™t able to make it work. Not sure if itā€™s the specific VM I had but the commands were producing failures, and I couldnā€™t properly update PHP.

On the other hand, I did contact Hansson IT and he was very good and updated PHP and the server very quickly, so hats off to him! Apparently, I need to brush up on my Linux skills.

Thanks again for everyoneā€™s insight

1 Like

Do you have paid version of VM or free as me? :slight_smile:

I paid for the VM last year.

Hanssonit NextCloud VM
I also have one of these. Also I am not able to get from php 7.4 to 8.X because of dependencies and certain setups. Also it is anything but trivial to move the NextCloud data and user settings to a more modern instance. I feel trapped.
I use the NC for our band without commercial background but I want to stay independent. Was it a mistake to use a pre-installed NC?

PECL are in place just to be able to get the absolute latest stable versions of the specific PHP dependencies - as Ubuntu repo maintainers usually are not catching up, which in turn could lead to security flaws (not running the latest updates). It happened before, and will happen again.

Thereā€™s a reasoning and thought behind every decision in the NcVM. We (mostly myself) have been developing it since back in 2014, even before Nextcloud was founded. Itā€™s solid! Stability is better than new features if you ask me.

Itā€™s your own choice to either install everything on your own, or download a pre-configured package, but as a lazy sysadmin I would prefer the latter - a pre-configured VM made by someone whoā€™s in love with Nextcloud and tried to make it as simple and secure as possible for everyone else to enjoy the benefits of freedom!

I didnā€™t have a clue about anything in 2013, so I built it mostly to help myself, then I figured, why not share it? And so I did. Now thousands and thousands of users have deployed it, and those deployments also require support from time to time, do you expect us to work for free?

Generally, if you just follow the recommendations written all over the internet (use the built in update script and update regularly) you are good to go for years to come (if not Nextcloud decide to deprecate a PHP version, and you donā€™t know how to upgrade) without any need for support. And hopefully, during that time, youā€™ve learned enough Linux to manage the PHP upgrades on your own. If not, we are here to help you - as a service - because we donā€™t need to really.

You can see it in two ways; either you applaud us for great work, or you think we are really stupid to charge for the services we offer. Which one are you? :slight_smile:

Iā€™ve been scratching my head to the same problem for a while now with the (apparently not full version of the HanssonIT) VMware image I downloaded from the Nextcloud website. Finally, I managed to solve it. Just putting the steps here hoping it might help other in the same predicament. Although, no guarantees, your mileage may varyā€¦

Also, long live the snapshot functionality of ESXi (or any other hypervisor for that matter)! Use it well and use it often, it saved me a lot during my journey to solve this.

Here it begins: I was on NC 25.0.9 and Ubuntu 20.04 LTS when I started, and stuck on PHP 7.4.

  1. First, add the following repository so you can install PHP 8.1
sudo add-apt-repository ppa:ondrej/php 
sudo apt update
  1. Then I updated to PHP 8.1 with these great instructions and script from ernolf:
    Any step by step documentation upgrading NC to 25? - #3 by ernolf
    Iā€™ll repeat the commands I used here, but all credits go to ernolf
    I kept all the old configuration parameters (the script will ask you to keep it or change it).
sudo wget -P /usr/local/bin https://global-social.net/apps/raw/s/php-updater
sudo chmod +x /usr/local/bin/php-updater
sudo php-updater

Should the script no longer be available in the future, you can always do it manually (update the packages and copy the configs).

  1. Manually set the PHP version with this command
for linkgroup in $(ls /var/lib/dpkg/alternatives/ | grep -E "ph(ar|p)"); do sudo update-alternatives --config $linkgroup; done
  1. The Nextcloud configuration of the VM uses php-fpm. Disable php7.4-fpm and enable php8.1-fpm with these commands
sudo a2disconf php7.4-fpm
sudo a2enconf php8.1-fpm
  1. Edit the Apache config to point to php8.1-fpm with nano. (If needed, change the path / name of the .conf file to your deployment.) Change the line that points to the old php7.4-fpm.nextcloud.sock to the new php8.1-fpm.sock (yes, without ā€˜nextcloudā€™)
sudo nano /etc/apache2/sites-enabled/nextcloud_http_domain_self_signed.conf
  1. You probably need to (re)install the corresponding version of the APCu package.
sudo apt-get install php8.1-apcu
  1. If needed, edit/create the following ā€˜apcu.iniā€™ files
In the following folders:
/etc/php/8.1/mods-available
/etc/php/8.1/fpm
/etc/php/8.1/cli

With the contents:
extension=apcu.so
apc.enable_cli=1
  1. If you use / have used SMB in external storage, you might need to update / reinstall the ā€˜smbclient.soā€™ dependency.
sudo apt -y install smbclient cifs-utils libsmbclient-dev php-dev make
sudo pecl install smbclient

Also, add this to your ā€˜/etc/php/8.1/fpm/php.iniā€™

'extension=smbclient.so'
  1. Time to finish!
sudo systemctl restart php8.1-fpm
sudo systemctl reload apache2

As youā€™ve probably deduced by now, Iā€™m definitely no ā€˜nativeā€™ Ubuntu / Linux user. So, some of the steps may not be needed per se or couldā€™ve been more efficient. But, it worked for me, so I hope this is useful for others in the same situation.

After above steps, Nextcloud was happily offering me the next update to 26.0.4 and then after that to 27.0.1 (current release version).

After the (finally) successful PHP update to 8.1, I also upgraded to Ubuntu 22.04 LTS. And Nextcloud kept on running after :slight_smile:

1 Like