PHP 8.1 on Ubuntu for Moodle 4.2.2

PHP 8.1 on Ubuntu for Moodle 4.2.2

by Farzad Shadafza -
Number of replies: 4
Hello 

My moodle version was 4.0.2 using php 7.4. Recently I have upgraded my moodle to 4.2.2 version. Once I did the upgrade I got an error on my website saying:

syntax error, unexpected '|', expecting variable (T_VARIABLE)

 I did some search and found out Moodle 4.2.2 requires php 8.0 or above. So I installed PHP 8.1 on my Server which is running Ubuntu 18.04. Once I installed php8.1 I tried to install PHP8.1 additional extension via codes like this:
 

sudo apt install graphviz aspell ghostscript clamav php8.1-pspell php8.1-curl php8.1-gd php8.1-intl php8.1-mysql php8.1-xml php8.1-xmlrpc php8.1-ldap php8.1-zip php8.1-soap php8.1-mbstring

when I execute this code I get lots of error indicating none of the extensions has been installed:


E: Unable to locate package php8.1-pspell

E: Couldn't find any package by glob 'php8.1-pspell'

E: Couldn't find any package by regex 'php8.1-pspell'

E: Unable to locate package php8.1-curl

E: Couldn't find any package by glob 'php8.1-curl'

E: Couldn't find any package by regex 'php8.1-curl'

E: Unable to locate package php8.1-gd

E: Couldn't find any package by glob 'php8.1-gd'

E: Couldn't find any package by regex 'php8.1-gd'

.... and the error goes on for all the extensions.


Would you please help me and tell why I can have these extension so I can run my new version of moodle? Thank You.





Average of ratings: -
In reply to Farzad Shadafza

Re: PHP 8.1 on Ubuntu for Moodle 4.2.2

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
"syntax error, unexpected '|', expecting variable (T_VARIABLE)" is typical for incompatible PHP versions.

May be not very helpful for your situation: Do you know that Moodle 4.1 LTS is compatible with PHP 7.4 and supported a year longer than Moodle 4.2? https://moodledev.io/general/releases.

Generally on PHP and Moodle compatibility, ref. http://www.syndrega.ch/blog/#php-and-dbms-compatibility-of-major-moodle-releases, especially the footnotes.

P.S. The topic is too technical for the Lounge. Better suited for the Installing and Upgrading help forum.
Average of ratings: Useful (1)
In reply to Farzad Shadafza

Re: PHP 8.1 on Ubuntu for Moodle 4.2.2

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
"So I installed PHP 8.1 on my Server which is running Ubuntu 18.04."

How?
Average of ratings: Useful (1)
In reply to Howard Miller

Re: PHP 8.1 on Ubuntu for Moodle 4.2.2

by Farzad Shadafza -
It seemed that I couldn't install php 8.1 on ubuntu 18.04. I mean I thought I did but it wasn't installed at all. So I install Ubuntu 20.04, then installed php 8.1 and the problem solved. 
listen learnedsmile) Php 8.1 cannot be installed on ubuntu 18.04 😁
Average of ratings: Useful (1)
In reply to Farzad Shadafza

Re: PHP 8.1 on Ubuntu for Moodle 4.2.2

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
It probably can... but you'd need to use a suitable PHP repository - which is why I asked "How?".

It's probably for the best as 18.04 is out of support (unless you're paying - as far as I know)
Average of ratings: Useful (1)