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
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
sudo chown -R ubuntu:ubuntu /var/www/<lms-domain-name>
4. Then
sudo chmod -R 777 /var/www/<lms-domain-name>
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
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.
sudo mysqldump —no-table-spaces -u username -p new_database < lms_database.sql
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 denied then, get into super user mode by typing the following command
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.