Trouble moving Moodle from Cpanel server to Fastpanel Server

Trouble moving Moodle from Cpanel server to Fastpanel Server

by Bryan Hane -
Number of replies: 20

I have migrated my moodle from a cpanel server to a fastpanel server.

I moved the wwwroot dir, moodledata dir and sql database just fine.

I then went to turn maintenance mode off on the new server and received this error after I added in the debug options on config.php

$a contents: syntax error, unexpected ':', expecting ')'
Stack trace: * line 4392 of /lib/outputrenderers.php: ParseError thrown
* line 632 of /lib/setup.php: call to require_once()
* line 34 of /config.php: call to require_once()
* line 28 of /admin/cli/maintenance.php: call to require()

I searched for this and noticed I had php7.4 install on the new fastpanel server and php8.0 on the old Cpanel server. I installed php8.0 on the new server and still received the same error.

What should I try next?

Thanks in advance

Average of ratings: -
In reply to Bryan Hane

Re: Trouble moving Moodle from Cpanel server to Fastpanel Server

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

Which version of Moodle do you have? Check the $release line in version.php in your Moodle source code folder, what does it say?

The likely cause is that your Moodle version does not support your PHP version. This table shows which PHP versions are supported by which Moodle version.

In reply to Leon Stringer

Re: Trouble moving Moodle from Cpanel server to Fastpanel Server

by Bryan Hane -
4.3.1+ (Build: 20231215)
In reply to Bryan Hane

Re: Trouble moving Moodle from Cpanel server to Fastpanel Server

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

Well Moodle 4.3.1+ should work with PHP 8.0. Presumably you can't get to the PHP info page in Moodle to check the PHP version. Try uploading a file containing <?php phpinfo(); and see which PHP version is shown at the top.

I suspect the web server is actually running PHP 7.4 so the unexpected ':' error is because of the use of named parameters in:

4392                 context: \core\context\course::instance($COURSE->id),

Named parameters were introduced in PHP 8.0.

In reply to Leon Stringer

Re: Trouble moving Moodle from Cpanel server to Fastpanel Server

by Bryan Hane -
It says php version 8.0.30
In reply to Bryan Hane

Re: Trouble moving Moodle from Cpanel server to Fastpanel Server

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

I'm running out of ideas. I still think PHP 7.4 is somehow being used because if I try the Moodle 4.3.1+ version of /lib/outputrenderers.php with PHP 7.4 I also get syntax error, unexpected ':', expecting ')' in lib/outputrenderers.php on line 4392.

Could there be some file like .htaccess in the Moodle site's home folder that's setting the PHP version for Moodle?

In reply to Leon Stringer

Re: Trouble moving Moodle from Cpanel server to Fastpanel Server

by Bryan Hane -
I do not see anything like that.

Not sure what else to do
In reply to Bryan Hane

Re: Trouble moving Moodle from Cpanel server to Fastpanel Server

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

In the absence of other ideas, you could edit the file lib/setup.php to insert die(phpversion()); on line 632:

 631 require_once($CFG->libdir .'/weblib.php');          // Functions relating to HTTP and content
 632 die(phpversion());
 633 require_once($CFG->libdir .'/outputlib.php');       // Functions for generating output

This should stop the code just before the PHP error and show the PHP version instead.

In reply to Leon Stringer

Re: Trouble moving Moodle from Cpanel server to Fastpanel Server

by Bryan Hane -
Your right it returned
7.4.3-4ubuntu2.28

Not sure why or where this is coming from
In reply to Bryan Hane

Re: Trouble moving Moodle from Cpanel server to Fastpanel Server

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

Well it's progress of sorts, we've confirmed the cause of the syntax error.

Is this a shared host or a VPS? If it's a VPS did you restart the web server processes after you upgraded to PHP 8.0? (Possibly this would be done with the command sudo systemctl restart apache2 php-fpm but I'm not an Ubuntu expert).

Either way if you can share details of how you switched from PHP 7.4 to 8.0 maybe we can work out the next steps. Including screenshots helps us understand what you're seeing (hide or crop anything you don't want to share on the Internet).

And don't forget to remove the die(phpversion()); from lib/setup.php.

In reply to Leon Stringer

Re: Trouble moving Moodle from Cpanel server to Fastpanel Server

by Bryan Hane -
First of all - thanks for all your help so far on this.

I am also contacting my host about this - they have said it is installed as php 8.0 in the directory and should work - I am sending them back more info too.

I am running a Vultr Server with Fastpanel on it.
I moved everything over via rsync

I changed the PHP version to 8.0 in the fastpanel gui and when I look at any page in the browser it lists it correctly.

It is mainly running this command
>php admin/cli/maintenance --disable

that I get the problem -
I tried running it as root and as the owner of the website/moodle directory - both had the same result.

Is there anyway to force which PHP version moodle points to?
I know there are several installed on the server - but should only be the 8.0 on this website.
In reply to Bryan Hane

Re: Trouble moving Moodle from Cpanel server to Fastpanel Server

by Bryan Hane -
Ok - they should be how to run it with php 8.0 - now I am getting a different error

but I did confirm that it is 8.0.30 version of php now

Here is the new error:
!!!

Error: database driver problem detected

The site administrator should verify server configuration

Unknown driver native/mysql


Debug info:
Error code: dbdriverproblem
Stack trace: * line 336 of /lib/dmllib.php: dml_exception thrown
* line 654 of /lib/setup.php: call to setup_DB()
* line 34 of /config.php: call to require_once()
* line 28 of /admin/cli/maintenance.php: call to require()

Any thoughts on this new issue - or should I open a different thread?
In reply to Leon Stringer

Re: Trouble moving Moodle from Cpanel server to Fastpanel Server

by Bryan Hane -
I also checked my DB versions were compatible with this version of moodle.

On the old Cpanel I was running MariaDB 10.6.19

On the new FastPanel I am running Mysql 8.0.36
In reply to Bryan Hane

Re: Trouble moving Moodle from Cpanel server to Fastpanel Server

by Ken Task -
Picture of Particularly helpful Moodlers

In config.php - DB array - DB type

Should say:

$CFG->dbtype    = 'mysqli';

And you should have php extensions to support the driver:

In code directory:

php -m |grep mysql

should display at least:

mysqli
mysqlnd

If those are not there, use FastPanel to see if you can enable mysql related extensions.

'SoS', Ken

In reply to Ken Task

Re: Trouble moving Moodle from Cpanel server to Fastpanel Server

by Bryan Hane -
Ken,

thanks - I think that was the final piece. It appears to be working now.

you and Leon have both been wonderful - I really appreciate your help.

Thanks
In reply to Bryan Hane

Re: Trouble moving Moodle from Cpanel server to Fastpanel Server

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers
As a casual observer, I wonder if you had to enable both mysqli and mysqlnd? On my VPS, using cPanel, I can only enable mysqlnd, yet mysqli does show, maybe because cPanel knows that this (almost) always should be enabled by default.

I am just trying to get a little educated by Ken and Leon, who are both great at these things.

Perhaps the moral of this story (discussion) is to ensure all required PHP extensions are enabled. From my notes for getting a server ready, I have these lines:
 

"PHP Extensions (Important for Moodle, some might already be enabled):
Note: I had to turn these back on when I upgraded from php 8.0 to php 8.1.
curl, exif (needed for M4.2), fileinfo, gd, iconv, intl, mbstring, mysqlnd, opcache, soap, sodium, xmlrpc (M4.2) no longer needed, zip
In Moodle 4.4.1+ (Build: 20240719), php extension tidy was needed."
In reply to Rick Jerz

Re: Trouble moving Moodle from Cpanel server to Fastpanel Server

by Ken Task -
Picture of Particularly helpful Moodlers

@Rick ... in config.php can have only one DB type line.

mysqlnd - is the 'native driver' (the nd) ... supposedly better - and if I am not mistaken, mysqli in config would use mysqlnd if present.   Doesn't hurt to have both installed.

Wanna deep dive into that?

https://dev.mysql.com/downloads/connector/php-mysqlnd/

Myself ... I prefer not to deep dive unless I have to! :|

Let's remember, you host on GoDaddy ... the OP does not.

Environment is everything ... that why one might see all sorts of questions - for panel, (heck of a difference in those depending upon hosting), for GUI Moodle Admin, as well as CLI with issues such as the OP had.

uname -an tends to surprise some folks as they think they've improved hosting ... maybe ... maybe not.

My 2 cents!

'SoS', Ken

In reply to Ken Task

Re: Trouble moving Moodle from Cpanel server to Fastpanel Server

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers
Thanks, Ken. I couldn't dive much deeper.

Yes, I host on GoDaddy using cPanel on my VPS, so I do a lot of behind-the-scenes administration. I have never had to worry about mysqli, but aways have had to enable mysqlnd.
In reply to Bryan Hane

Re: Trouble moving Moodle from Cpanel server to Fastpanel Server

by Ken Task -
Picture of Particularly helpful Moodlers

Welcome!  Good to hear ... but ...

now for checking things that aren't under control of moodle ... important that you setup a cron job for your moodle - execute once per minute.

Since you migrated using rsync (I don't know how one uses rsync to migrate a DB, BTW), would also be a good idea to check system using code/admin/cli/ scripts for the DB (server and DB for moodle).

Since you mentioned 'other instances of something' (not disclosed) it also might be a good idea to install MySQLTuner - a perl script - and run it with superuser credentials for your DB server.

Your 'journey' may not be over yet ... actually, admin of a moodle is never over ... and in near future, you will be upgrading your moodle ... 4.3 is no longer supported for fixes to code nor security fixes.

For now, you've migrated ... time to start monitoring and tweaking, etc. smile

'SoS', Ken

In reply to Ken Task

Re: Trouble moving Moodle from Cpanel server to Fastpanel Server

by Bryan Hane -
Ken

I followed this video for most of the move:


this had me do a mysqldump and load it back in - I just used rsync to move all the files since it was about 20GB worth of stuff.

The video did have me setup a cron job on the new server too.

I was just helping move this site to the new server - I am not their normal server admin - I will pass on your suggestion to the normal admin who maintains their site.

Thanks
In reply to Bryan Hane

Re: Trouble moving Moodle from Cpanel server to Fastpanel Server

by Ken Task -
Picture of Particularly helpful Moodlers

Pardon jumping in here ... Leon is not giving you bad suggestions ... I just have some additions. smile

cpanel server to a fastpanel server
suggest you've also moved providers.   Mind sharing what provider?
and, if you've moved from shared hosting to a VPS?

4.3.1+ (Build: 20231215)
4.3 PHP Min: 8.0[8] PHP Max 8.2

Do you have a terminal icon in fastpanel?
If so, execute the following from the code directory:
php -v
php -m

ls .htaccess

In your fastpanel, is there an icon for multiple php's?

This line:

$a contents: syntax error, unexpected ':', expecting ')'

does indicate wrong php version.  You must have min. of php 8.0 + php extensions to run a 4.3.x.

Is there a climaintenance.html page in your moodledata directory?   If so erase/delete the file.

line 632 of /lib/setup.php
require_once($CFG->libdir .'/accesslib.php');       // Access control functions
 * This file contains functions for managing user access

So the user you are logging into the moodle as ... is it admin level?

'SoS', Ken