In this scenario, we will cover a situation where you are either setting up the LMS on another account or migrating it to another instance. The prerequiste for this are:
A ready and running instance
Domain virtual host file created
Server up and running
Once youre certain all the above are working, then we will go through the steps below to re-install the LMS
Upload the LMS files via FTP and Unzip the contents
Create an empty database to upload the LMS database sql contents
Configure the virtual host file
Edit the LMS config.php file
Finalizing LMS installation
Step 1 — Upload the LMS files via FTP and Unzip the contents
Before going through the upload, we ensure that we have setup the folder that will host the LMS.
1. Through the terminal of your choice, navigate to the following directory: /var/www
2. Next create an emtpy directory with the name of domain name hosting the LMS
sudo mkdir -p /var/www/<lms-domain-name>
3. Next set up the following folder ownership and permission
Now we can proceed to uploading the lms the respective folder.
5. Connect to the instance through the FTP software - FileZilla in this case- If you would like to know how to connect to your Instance through FTP, follow the steps in this link:
Now once we know that we are connected, navigate to the directory path /var/www. Check to see that we can view the directory we created above. If you can view it, drag and drop the archive/zipped file to that folder.
6. Once done, let go back to our terminal and unzip it using the following command
sudo unzip <name-of-archive>.zip
If unzipped correctly we should see the folders, moodle, moodledata and <lms_database>.sql
Step 2 — Create an empty database to upload the LMS sql contents
Next we will create an empty database and then upload the sql content we have unzipped from the archive.
To do this, log in to mysql shell
sudo mysql -u root -p
If during secure installation of the MySQL Driver, you set up a password for the root account, enter the same password, otherwise hit enter to auto log in without a password
1. Now lets create the database using the following commands, terminated with a semi-colon. (Replace <database_name> with an actual name for the database)
Note: Use the same database name, user and password that you used when initially installing the LMS
create database <database_name>;
CREATE USER ‘<user>’@’localhost’ IDENTIFIED BY ‘<password>’;
GRANT ALL PRIVILEGES ON <database_name>.* TO ‘<user>’@’localhost’;
FLUSH PRIVILEGES;
Note: If you perhaps get a syntax error of some sort, delete and retype the quote marks.
2. Exit the mysql shell by typing out exit
3. Ensuring that we are still in the same folder as the sql file that we extracted from the archive, enter the following command to upload the sql file values into the database we created above.
username is the user we created and assigned to the database
new_database is the name of the freshly created database
lms_database.sql is the sql file to be imported, located in the current directory
If the command we have entered above brings up the following error -bash: Permission deniedthen, get into super user mode by typing the following command
sudosu
Then enter the mysqldump upload command above. It should prompt you to enter password, which the the database user password you created when setting up the database in step 1.
If everything worked correctly, the database will bring back a null message.
Finally type exit to exit Super user mode.
Step 3 — Configure the virtual host file
Let’s now configure the virtual host file to point to the directory we have installed the LMS on. Ensure that you have already created the virtual host file by following the steps in this
Under the Document Root, ensure that the path point to the folder we created in Step 1
The same goes for the <Directory> tag below it.
Once done with the changes, click CTRL - X to exit, and hit Y then Enter to save your changes.
Then enter the following two commands to enable to the LMS
sudo a2ensite <lms_domain_name>.conf
To restart the apache2 server run:
sudo systemctl reload apache2
Step 4 — Edit the LMS config.php file
Now lets edit the config.php file in the Moodle LMS to show match the path we set up in the virtual host file above. To do this, navigate to the LMS main system folder through the following command
cd /var/www/<lms_domain_name>/moodle
Next we will enter the following command to edit the config.php file
The fields highlighted in blue are the once we will change to match the correct details of the database and also the correct lms path and moodledata location.
Once done with the changes, click CTRL - X to exit, and hit Y then Enter to save your changes.
Step 5 — Finalizing the re-installation
In this step, we will enable the SSL certificate for the LMS using certbot. If you dont have certbot installed on the new instance, follow the steps in this
On the output, enter the option 2 to make all requests redirect to secure HTTPS access.
Finalize by reloading the server using the following command
sudo systemctl reload apache2
Finally, access the LMS through the browser through the domain name you used to set up the LMS. If all worked well, you should be greeted by the LMS’ log in page!
Want to print your doc? This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (