How to Update PHP Version so Moodle Upgrade Works

Hi Juan,

Thank you for the reply.

I got all the way to the step:
chmod +x bitnami-moodle-3.1.3-0-linux-x64-installer.run
./bitnami-moodle-3.1.3-0-linux-x64-installer.run

and then I ran into an issue.

I was asked for my password, but when I typed it in, no letters appeared. Is that normal?

It did not say whether or not that worked or not, but it did let me continue on with the installation. I answered yes to all the questions, and then it asked me where I wanted to install the new stack.

I put in /opt/bitnami/ but I got an error that with the current user, I was not allowed to perform that operation.

Do I have to log in somehow on the terminal in order to complete the stack update?

Please let me know. Thanks,

Benjamin Gee

Hello,

Yes, it is normal. For security reasons the password you introduce there won’t be shown in your terminal screen.

Please note that your user hasn’t had write permissions in that folder. If you want to install your new stack there just execute the installer as root:

sudo ./bitnami-moodle-3.1.3-0-linux-x64-installer.run

Hope it helps,
Jose

Hi Jose,

So something very serious happened. I followed your commands, and everything seemed to be working fine. I got through the steps to update the stack, and then restored the database backup, and then performed the steps to update the moodle version.

When I navigated to the website, I got the error shown in my attachment, that the data base connection failed. I could not figure out the issue, so I restored my moodle site using the restore commands provided by bitnami.

cd /your/directory
sudo /opt/bitnami/ctlscript.sh stop
sudo tar -pczvf application-backup.tar.gz /opt/bitnami
sudo /opt/bitnami/ctlscript.sh start

As it was restoring the backup, I noticed lots of commands about actions not being able to be performed because of lack of memory. When I used the restart command, it kept trying to restart the mysql, but it did not seem to work. In fact, even by pressing control C, it would not stop it from trying to restart.

What is even worse is now, using the google cloud platform, I am unable to access the virtual machine.

I have no idea what to do now or what went wrong. Please let me know what steps I should take next. Thank you,

Benjamin Gee

Hi Jose,

We stopped and started the VM on the google cloud platform, and now we can access the virtual machine through the SSH. So that part is good. But something did go wrong with the PHP update, because we are still running 5.5.30.

I tried to use the stop and restart server commands in the command terminal, but as you can see below, there are quite a few errors. Do you know what steps I should take next?

Thank you,
Benjamin Gee

benjamin_g@moodle-1:~$ /opt/bitnami/php/bin/php -v
PHP 5.5.30 (cli) (built: Nov 14 2015 21:19:36)
Copyright © 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright © 1998-2015 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright © 1999-2015, by Zend Technologies
benjamin_g@moodle-1:~$ sudo /opt/bitnami/ctlscript.sh stop
httpd.bin: Syntax error on line 560 of /opt/bitnami/apache2/conf/httpd.conf: Syntax error on line 30 of
/opt/bitnami/apache2/conf/bitnami/bitnami.conf: Syntax error on line 2 of /opt/bitnami/apache2/conf/bitn
ami/bitnami-apps-prefix.conf: Could not open configuration file /opt/bitnami/apps/moodle/conf/httpd-pref
ix.conf: No such file or directory
apache config test fails, aborting
/opt/bitnami/php/scripts/ctl.sh : php-fpm stopped
/opt/bitnami/mysql/scripts/ctl.sh : mysql stopped
benjamin_g@moodle-1:~$ sudo /opt/bitnami/ctlscript.sh restart
monit: action failed – Other action already in progress – please try again later
monit: action failed – Other action already in progress – please try again later
monit: action failed – Other action already in progress – please try again later
monit: action failed – Other action already in progress – please try again later
httpd.bin: Syntax error on line 560 of /opt/bitnami/apache2/conf/httpd.conf: Syntax error on line 30 of
/opt/bitnami/apache2/conf/bitnami/bitnami.conf: Syntax error on line 2 of /opt/bitnami/apache2/conf/bitn
ami/bitnami-apps-prefix.conf: Could not open configuration file /opt/bitnami/apps/moodle/conf/httpd-pref
ix.conf: No such file or directory
apache config test fails, aborting
/opt/bitnami/php/scripts/ctl.sh : php-fpm not running
/opt/bitnami/mysql/scripts/ctl.sh : mysql not running
170116 20:06:46 mysqld_safe Logging to ‘/opt/bitnami/mysql/data/mysqld.log’.
170116 20:06:46 mysqld_safe Starting mysqld.bin daemon with databases from /opt/bitnami/mysql/data
/opt/bitnami/mysql/scripts/ctl.sh : mysql started at port 3306
[16-Jan-2017 20:06:53] WARNING: Nothing matches the include pattern ‘/opt/bitnami/apps/moodle/conf/php-f
pm/pool.conf’ from /opt/bitnami/php/etc/php-fpm.conf at line 397.
[16-Jan-2017 20:06:53] WARNING: Nothing matches the include pattern ‘/opt/bitnami/apps/phpmyadmin/conf/p
hp-fpm/pool.conf’ from /opt/bitnami/php/etc/php-fpm.conf at line 399.
/opt/bitnami/php/scripts/ctl.sh : php-fpm started
httpd.bin: Syntax error on line 560 of /opt/bitnami/apache2/conf/httpd.conf: Syntax error on line 30 of
/opt/bitnami/apache2/conf/bitnami/bitnami.conf: Syntax error on line 2 of /opt/bitnami/apache2/conf/bitn
ami/bitnami-apps-prefix.conf: Could not open configuration file /opt/bitnami/apps/moodle/conf/httpd-pref
ix.conf: No such file or directory
apache config test fails, aborting
monit: action failed – Other action already in progress – please try again later
monit: action failed – Other action already in progress – please try again later
monit: action failed – Other action already in progress – please try again later
monit: action failed – Other action already in progress – please try again later

Hello,

This error could be related to an error with the content of the config.php file of your Moodle installation. Please note that this file contains the information needed by Moodle to be able to connect to the database you have created.

Could you go again through the steps you have followed until you receive again this error?

At this point, please, open the /opt/bitnami-backup/apps/moodle/htdocs/config.php file and check that it contains the correct configuration of your database.

If you are having troubles checking this file, you can share it with us and we can take a look to it, but remember to remove any sensible information like the database password of the file before you share it with us.

Regards,
Jose

Hi Jose,

I followed the commands below:

mysqldump -u root -p bitnami_moodle > backup.sql
sudo /opt/bitnaim/ctlscript.sh stop
sudo mv /opt/bitnami/ /opt/bitnami-backup/
wget https://downloads.bitnami.com/files/stacks/moodle/3.1.3-0/bitnami-moodle-3.1.3-0-linux-x64-installer.run
chmod +x bitnami-moodle-3.1.3-0-linux-x64-installer.run
sudo ./bitnami-moodle-3.1.3-0-linux-x64-installer.run

I followed the installation set up, completing the tasks as they were asked. Then I followed the final command:

mysql -u root -p bitnami_moodle < backup.sql

Then I began to moodle update using the following commands:

sudo mv /opt/bitnami/apps/moodle/htdocs/ /opt/bitnami/apps/moodle/htdocs.backup
wget https://download.moodle.org/download.php/direct/stable32/moodle-3.2.1.tgz
sudo mkdir /opt/bitnami/apps/moodle/htdocs/
sudo tar -xzvf moodle-3.2.1.tgz -C /opt/bitnami/apps/moodle/htdocs/ --strip 1
sudo cp -a /opt/bitnami-backup/apps/moodle/htdocs.backup/config.php /opt/bitnami/apps/moodle/htdocs/
sudo cp -a /opt/bitnami-backup/apps/moodle/htdocs.backup/theme/MY_THEME /opt/bitnami/apps/moodle/htdocs/theme/
sudo cp -a /opt/bitnami-backup/apps/moodle/htdocs.backup/mod/MY_MOD /opt/bitnami/apps/moodle/htdocs/mod/

I then navigated to the website, and I got the “database connection” failed error

Then I tried to restore my previous backup so that the website would be up and running temporarily using the following commands:

cd /your/directory
sudo /opt/bitnami/ctlscript.sh stop
sudo mv /opt/bitnami /tmp/bitnami-backup
sudo tar -pxzvf application-backup.tar.gz -C /

It was at that point when I noticed a considerable amount of errors as I tried to restore the back up. Lots of commands said were not possible becaue of lack of memory. I then used the restart command using the following:

sudo /opt/bitnami/ctlscript.sh start

That command did not work properly and that is when I lost connection to the VM terminal. After stopping and staring the VM in the google cloud, I was able to gain access again.

Here is the output of the /opt/bitnami-backup/apps/moodle/htdocs/config.php command

benjamin_g@moodle-1:~$ ls -la /opt/bitnami-backup/apps/moodle/htdocs/config.php
-rw-rw-r-- 1 bitnami daemon 1085 Dec 18 2015 /opt/bitnami-backup/apps/moodle/htdocs/config.php
benjamin_g@moodle-1:~$ ls /opt/bitnami-backup/apps/moodle/htdocs/config.php
/opt/bitnami-backup/apps/moodle/htdocs/config.php

I am not entirely sure if I shared that with you correctly, but please let me know. I have also attached the serial consule output, which might be of some help.

Thanks,

Benjamin Gee

Hello,

Your steps seem right. However, you are restoring the themes from your old Moodle installation from the new one by executing:

sudo cp -a /opt/bitnami-backup/apps/moodle/htdocs.backup/theme/MY_THEME 

Please note that is not possible since Moodle 3.2.1 use another different template engine from the previous version.

On the other hand, this is the command you need to execute in order to share with us the content of the config.php file:

cat /opt/bitnami-backup/apps/moodle/htdocs/config.php

Sorry for not being enough clear. I would like to remember you to remove any sensible information like the database password of the file before you share it with us.

Finally, I would like to let you know that we are currently working on releasing the new Moodle 3.2 version of our Cloud Images. When we release it you only need to launch a new instance using the new Moodle 3.2 version and then restoring the database from your previous installation to this new one. If you prefer, you can wait until we release this new version since this process would be much easier as updating by yourself the installation. We could let you know when we release this new version.

Hope it helps,
Jose

Hi Jose,

here is the output of that command:

benjamin_g@moodle-1:~$ cat /opt/bitnami-backup/apps/moodle/htdocs/config.php

<?php // Moodle configuration file unset($CFG); global $CFG; $CFG = new stdClass(); $CFG->dbtype = 'mysqli'; $CFG->dblibrary = 'native'; $CFG->dbhost = 'localhost'; $CFG->dbname = 'bitnami_moodle'; $CFG->dbuser = 'bitnami'; $CFG->dbpass = ''; $CFG->prefix = 'mdl_'; $CFG->dboptions = array ( 'dbpersist' => 0, 'dbport' => 3306, 'dbsocket' => '/opt/bitnami/mysql/tmp/mysql.sock', ); if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { $CFG->wwwroot = 'https://' . $_SERVER['HTTP_HOST']; } else { $CFG->wwwroot = 'http://' . $_SERVER['HTTP_HOST']; }; $CFG->dataroot = '/opt/bitnami/apps/moodle/moodledata'; $CFG->admin = 'admin'; $CFG->directorypermissions = 02775; $CFG->passwordsaltalt1 = '**************************************************************************'; $CFG->passwordsaltmain = '*************************************************************************'; require_once(dirname(__FILE__) . '/lib/setup.php'); // There is no php closing tag in this file, // it is intentional because it prevents trailing whitespace problems! Does there seem to be a problem with that?

Hi Jose,

Could you give me instructions for launching a new instance using the new Moodle 3.2 version and how to restore the database from my previous installation?

Do you have a time frame for the new release?

Thank you
Benjamin Gee

Hello,

In order to test the credentials stored in that file, could you please execute the following commands?

  • Look for the following lines in your config.php file:
$CFG->dbname = 'bitnami_moodle';
$CFG->dbuser = 'bitnami';
$CFG->dbpass = '';
  • Execute the following command on your server to test those credentials are valid:
mysql -u[dbuser] -p[dbpass] 

Substitute [dbuser] and [dbpass] with the value you have obtained in the previous step. For example, [dbuser] would be bitnami, do the same with [dbpass]. If [dbpass] would be 1234and [dbuser] would bebitnami` the command should be the following one:

mysql -ubitnami -p1234
  • If the previous command is executed correctly, you should be something like this:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 35
Server version: 10.1.21-MariaDB Source distribution

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>
  • In the previous console, execute the following:
SHOW DATABASES;

You should see something like that:

+--------------------+
| Database           |
+--------------------+
| bitnami_moodle     |
| information_schema |
+--------------------+
2 rows in set (0.00 sec)
  • Execute the following command:
USE bitnami_moodle;

You should be something like that:

MariaDB [(none)]> USE bitnami_moodle;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

Let us know if you receive some kind of error execute any of the previous steps.

We expect to have the new release during next week. I recommend you to wait until we release this new version since this whole process would be much easier.

Regards,
Jose

Hi Jose,

I received no problems with those commands. Here is the output:

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.27 MySQL Community Server (GPL)
Copyright © 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
No entry for terminal type “xterm-256color”;
using dumb terminal settings.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql> SHOW DATABASES;
±-------------------+
| Database |
±-------------------+
| information_schema |
| bitnami_moodle |
| test |
±-------------------+
3 rows in set (0.04 sec)
mysql> USE bitnami_moodle;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed

The only thing I noticed is that my server version is 5.6.27, not 10.1.21 like your example. Is this a problem? What should I execute next?

Thank you,

Benjamin Gee

Hello,

We don’t ship MySQL but MariaDB in our Moodle cloud images. Did you install it by yourself using apt-get?

In any case, we have just release Moodle 3.2.1 in Bitnami. To launch a new instance with the new image just go to https://bitnami.com/stack/moodle, click in Launch in the Cloud and select the cloud you prefer.

Once you have launched a new instance with the new Moodle installation, you only need to follow the steps described in the following guide:

https://docs.bitnami.com/google/apps/moodle/#how-to-migrate-your-moodle-installation

Finally, you only need to navigate to the application from a browser and follow the steps to upgrade the database to the latest version.

Let us know if you find any trouble in any of the steps described in the guide.

Regards,
Jose

I didn’t not install that on my own. Do you understand why that is there?

When I tried to updated the PHP version and it did not work, I tried to restore using my old backup, and that is when I got the major errors involving not enough memory.

Since I can’t navigate to the webpage now, will I still not be able to navigate it once I migrate the system to the new image?

Hi Jose,

I have a few questions regarding migrating the moodle installation. In the step: Copy the Moodle Data Folder, it says:

“you just need to copy the /opt/bitnami/apps/moodle/moodledata directory to the machine where you have installed the new Moodle. When doing this step, copy the exported database file too. If you have themes or modules installed and you want to keep them, you must also copy them”

Additionally, the instructions say: you just need to substitute the moodledata/ directory, as well as the themes/ and modules/ directories if needed

So my questions are:

  1. How do you copy the /opt/bitnami/apps/moodle/moodledata directory to the new machine?

  2. How do you copy the themes and modules installed to the new machine?

  3. How do you substitute the moodledata/ directory?

  4. How do you substitute the themes’ and modules’ directories?

  5. Given that when you navigate to the current site you cannot access the moodle site, as I tried to backup to the old moodle version after it seemed the PHP/moodle update failed, do you expect any issues for me to face once we have successfully migrated the moodle version? Will I need to do anything to possibly re-mediate what is currently wrong with the site? Whatever that may be?

Thank you,

Benjamin Gee

Hello,

For that purpose, you can copy that directory from your old machine to your local computer and then to your local computer to your new machine. You can use an external program like FileZilla. We have the necessary steps to configure FileZilla to upload and download files from your server in this guide:

https://docs.bitnami.com/google/faq/#how-to-upload-files-to-the-server-with-sftp

This is the same as the previous point, in this case, you should download to your local computer the following folders:

/opt/bitnami/apps/moodle/htdocs/theme/
/opt/bitnami-backup/apps/moodle/htdocs/mod/

Then, upload those folders to the same location but in your new machine using FileZilla as you did in the previous step.

This is related to the first step. Substitute the moodledata/ directory means that you have to upload the moodledata/ dir you have downloaded from your old server to your new one using, for example, FileZilla

This is, as well, related to the second step. That means that you have to upload the /opt/bitnami/apps/moodle/htdocs/theme/ and /opt/bitnami/apps/moodle/htdocs/mod/ directories you have downloaded from your old server to your new one using FileZilla

Once you have migrated all your data to your new server, you will navigate to the IP the new server has and you will see a wizard to upgrade the database to the new version of Moodle.

Regards,
Jose

hi, I am also experiencing this problem however, using

sudo tail -n 100 /opt/bitnami/mysql/data/mysqld.log

showed the error was permission related. After correcting the error

sudo nano /opt/bitnami/apps/moodle/htdocs/config.php

i now get

Not Found The requested URL /admin/index.php was not found on this server

My second attempt was to migrate the data over to a windows platform as apposed to using a bitnami VM, however, I get

The webpage cannot be found

when trying to login. I am unsure if this is LDAP plugins being required for php and SSL settings to be all setup. Any suggestions to resolve this upgrade issue would be great :slight_smile: thankful for snapshots.

Upgrade Steps

sudo /opt/bitnami/ctlscript.sh stop
sudo mv /opt/bitnami/ /opt/bitnami-backup/
wget --no-check-certificate https://bitnami.com/redirect/to/183645/bitnami-moodle-3.4.2-0-linux-x64-installer.run
sudo chmod +x bitnami-moodle-3.4.2-0-linux-x64-installer.run ./bitnami-moodle-3.4.2-0-linux-x64-installer.run
sudo ./bitnami-moodle-3.4.2-0-linux-x64-installer.run
mysql -u root -p bitnami_moodle < backup.sql
sudo mv /opt/bitnami/apps/moodle/htdocs/ /opt/bitnami/apps/moodle/htdocs.backup
wget https://download.moodle.org/download.php/direct/stable34/moodle-3.4.2.tgz --no-check-certificate
sudo mkdir /opt/bitnami/apps/moodle/htdocs/
sudo tar -xzvf moodle-3.4.2.tgz -C /opt/bitnami/apps/moodle/htdocs/ --strip 1
sudo cp -a /opt/bitnami-backup/apps/moodle/htdocs.backup/config.php /opt/bitnami/apps/moodle/htdocs/
// also tried: sudo cp -a /opt/bitnami-backup/apps/moodle/htdocs/config.php /opt/bitnami/apps/moodle/htdocs/
sudo cp -a /opt/bitnami-backup/apps/moodle/htdocs.backup/theme/darkb /opt/bitnami/apps/moodle/htdocs/theme/
sudo /opt/bitnami/ctlscript.sh restart
sudo cp -a /opt/bitnami-backup/apps/moodle/htdocs.backup/config.php /opt/bitnami/apps/moodle/htdocs/
cat /opt/bitnami-backup/apps/moodle/htdocs/config.php
sudo nano /opt/bitnami-backup/apps/moodle/htdocs/config.php
sudo /opt/bitnami/ctlscript.sh restart
mysql -uroot -p
SHOW DATABASES;
USE bitnami_moodle;

Result was Database changed :slight_smile:

sudo /opt/bitnami/ctlscript.sh restart

Hi,

Could you please provide us a little more information?

  • Are you using this application in a Cloud Provider (AWS, Google, Azure, …), in the native installer (Windows, Linux, OS X) or in a VM?
  • Which exact version of the application are you upgrading from?

Do you follow this guide?
https://docs.bitnami.com/google/apps/moodle/#how-to-upgrade-moodle

We have a Support Tool that will gather relevant information for us to debug the issue. Could you please download and execute it on the machine where the stack is running by following the steps described in the guide below?

How to Run the Bitnami Support Tool

Please note that you need to paste the code outputted by the tool in your reply.

Best regards,
Carlos R. Hernández

Hi Carlos,

Thank you for the reply. I am using a Bitnami VM appliance (bitnami-moodle-3.1.2-0-linux-ubuntu-14.04-x86_64), I am trying to upgrade from Moodle 3.1+ (Build: 20160616), PHP version 5.5.27. I have https enabled as well as removal of the bitnami landing page. The support tool generates files in a zip:

bnsupport_version = 0.6.1
installdir = /opt/bitnami
base_stack_key = moodle
base_stack_name = Bitnami Moodle Stack
base_stack_version = 3.4.2-0
base_stack_platform = linux-x64
require_root_privileges = 1
installtype = production
system_locale = en.US.UTF-8
system_username = root
user_home_directory = /home/bitnami
machine_free_disk_space = 3241 MB
machine_cpu_count = 1
machine_cpu_speed = 2300 MHz
machine_fqdn = linux
machine_hostname = linux
machine_ipaddr = 127.0.0.1
machine_swap_memory = 975 MB
machine_total_memory = 1995 MB
platform_has_smp = 0
os_family = linux
linux_distribution = ubuntu
linux_distribution_codename = trusty
linux_distribution_description = Ubuntu 14.04.3 LTS
linux_distribution_fullname = Ubuntu
linux_distribution_id = Ubuntu
linux_distribution_shortname = ubuntu
linux_distribution_version = 14.04
linux_distribution_release = 14.04

Hi @iHaag,

We need the code that the Bitnami Support tool generates at the end in order to retrieve your files properly, could you please share with us that ID?

Thanks.

Hi @iHaag,

2 years on and I have the exact same issue as you have described: 404 Not found. I have performed the same steps you have and am also running within a VM. Did you manage to get this resolved? Can you share the steps taken/ the correct migration steps?

Thanks,
Doug