{"id":28327,"date":"2018-10-02T04:11:52","date_gmt":"2018-10-02T09:11:52","guid":{"rendered":"https:\/\/www.rosehosting.com\/blog\/?p=28327"},"modified":"2022-12-09T06:52:19","modified_gmt":"2022-12-09T12:52:19","slug":"how-to-install-moodle-on-centos-7","status":"publish","type":"post","link":"https:\/\/www.rosehosting.com\/blog\/how-to-install-moodle-on-centos-7\/","title":{"rendered":"How to install Moodle on CentOS 7"},"content":{"rendered":"
<\/p>\n
Moodle is\u00a0a popular open-source learning management system (LMS) written in PHP. It was built to help educators easily create quality online courses.\u00a0In this article, we will show you how to install Moodle on\u00a0a\u00a0CentOS 7<\/a>.<\/p>\n <\/p>\n In order to run Moodle on your CentOS 7 server, you need the following requirements pre-installed:<\/p>\n Log in to your CentOS 7 VPS via ssh as user root<\/p>\n Once you are logged in to the server run the following command to make sure that all installed packages are up to date<\/p>\n As mention in the requirements section of the tutorial, a LAMP stack (Apache, MySQL\/MariaDB, and PHP) is required to run Moodle on the server. We will start with installing Apache web server<\/p>\n Start the Apache web server and enable it to start upon server boot<\/p>\n PHP version 7.1 is not available in the default CentOS 7 repositories so we will use the Remi repository.<\/p>\n To install and enable both EPEL and Remi repositories run the following commands:<\/p>\n Install PHP 7.1 and all necessary PHP modules using the following command:<\/p>\n During the installation, the yum package manager will prompt you to install the Remi GPG Signing key. Accept the key by typing ‘y’ and the package manager will install all necessary PHP extensions.<\/p>\n In order to complete the LAMP installation, install the MariaDB database server using the following command:<\/p>\n Start the MariaDB service and set it to start on reboot<\/p>\n Run the ‘mysql_secure_installation’ post-installation script provided by MariaDB to strengthen the security of the database server and set a root password. You can use the following options:<\/p>\n Moodle is not available in the official CentOS 7 repositories, so we will have to download the latest stable version from the official website page at https:\/\/download.moodle.org\/releases\/latest\/ and extract the Moodle archive to a directory on the server by executing the following commands:<\/p>\n This will create a new directory named \u2018moodle\u2019 containing the necessary files and directories. Create a new Apache configuration file and add the following contents below to the \/etc\/httpd\/conf.d\/moodle.conf file using vi or your favorite text editor:<\/p>\n Add the following lines:<\/p>\n <VirtualHost *:80> Alias \/moodle “\/var\/www\/html\/moodle\/” <\/Directory><\/p>\n ErrorLog \/var\/log\/httpd\/moodle-error_log Save the changes and restart the Apache web server for the changes to take effect:<\/p>\n Log into MariaDB with the root account:<\/p>\n Now we will create a MariaDB database for Moodle using the following query:<\/p>\n Add a separate user for Moodle that will interact with the database:<\/p>\n Execute the following command to apply the privileges we set:<\/p>\n Now we can exit the MariaDB session:<\/p>\n Edit the MariaDB configuration file (\/etc\/my.cnf.d\/server.cnf) and add the following lines:<\/p>\n Restart MariaDB service for the changes to take effect<\/p>\n You can now open a web browser and access the Moodle application at http:\/\/your-domain.com<\/p>\n From here you can finish the setup by following the steps below:<\/p>\n <\/p>\n That’s it, now you should have successfully installed Moodle on your CentOS 7 server.<\/p>\n Of course, you don\u2019t have to install and configure Moodle on CentOS 7, if you use one of our\u00a0Managed Moodle Hosting<\/a> solutions, in which case you can simply ask our expert Linux admins to install and configure Moodle on CentOS for you. They are available 24\u00d77 and will take care of your request immediately.<\/p>\n PS<\/strong><\/span>. If you liked this post on how to install and configure Moodle on a CentOS VPS, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.<\/p>\n","protected":false},"excerpt":{"rendered":" Moodle is\u00a0a popular open-source learning management system (LMS) written in PHP. It was built to help educators easily create quality … <\/p>\nMoodle Requirements<\/strong><\/h3>\n
\n
1. Login via SSH<\/strong><\/h3>\n
ssh roo@IP_Address -p Port_number<\/pre>\n
2. Update all packages<\/strong><\/h3>\n
yum clean all\r\nyum update<\/pre>\n
3. Install LAMP stack<\/strong><\/h3>\n
yum -y install httpd<\/pre>\n
systemctl enable httpd<\/pre>\n
yum install epel-release\r\nrpm -Uhv https:\/\/rpms.remirepo.net\/enterprise\/remi-release-7.rpm\r\nyum-config-manager --enable remi-php71<\/pre>\n
yum install php php-common php-intl php-zip php-soap php-xmlrpc php-opcache php-mbstring php-gd php-curl php-mysql php-xml<\/pre>\n
yum -y install mariadb mariadb-server<\/pre>\n
systemctl start mariadb\r\nsystemctl enable mariadb<\/pre>\n
Set root password? [Y\/n] Y\r\nRemove anonymous users? [Y\/n] Y\r\nDisallow root login remotely? [Y\/n] Y\r\nRemove test database and access to it? [Y\/n] Y\r\nReload privilege tables now? [Y\/n] Y<\/pre>\n
4. Install Moodle on CentOS 7<\/strong><\/h3>\n
cd \/opt\r\nwget https:\/\/download.moodle.org\/download.php\/direct\/stable35\/moodle-latest-35.tgz -O moodle-latest.tgz\r\ntar -xvzf moodle-latest.tgz\r\nmv \/opt\/moodle\/ \/var\/www\/html\/moodle\/<\/pre>\n
\nChange the ownership of the\u00a0\/var\/www\/html\/ directory:<\/p>\nchown -R apache:apache \/var\/www\/html\/<\/pre>\n
5. Configure Apache to serve Moodle<\/h3>\n
# vi \/etc\/httpd\/conf.d\/moodle.conf<\/pre>\n
\nServerAdmin admin@your-domain.com
\nDocumentRoot \/var\/www\/html\/moodle
\nServerName your-domain.com
\nServerAlias www.your-domain.com<\/p>\n
\n<Directory \/var\/www\/html\/moodle\/>
\nOptions +FollowSymlinks
\nAllowOverride All<\/p>\n
\nCustomLog \/var\/log\/httpd\/moodle-access_log common
\n<\/VirtualHost><\/p>\nsystemctl restart httpd<\/pre>\n
6. Create a MariaDB database for Moodle<\/h3>\n
# mysql -u root -p<\/pre>\n
mysql> CREATE DATABASE moodledb;<\/pre>\n
mysql> GRANT ALL PRIVILEGES ON moodledb.* to 'moodle'@'localhost' IDENTIFIED BY '5tr0ng_Pa55w0rd';<\/pre>\n
mysql> FLUSH PRIVILEGES;<\/pre>\n
mysql> quit<\/pre>\n
[client]\r\ndefault-character-set = utf8mb4\r\n\r\n[mysqld]\r\ninnodb_file_format = Barracuda\r\ninnodb_file_per_table = 1\r\ninnodb_large_prefix\r\ncharacter-set-server = utf8mb4\r\ncollation-server = utf8mb4_unicode_ci\r\nskip-character-set-client-handshake\r\n\r\n[mysql]\r\ndefault-character-set = utf8mb4<\/pre>\n
service mariadb restart<\/pre>\n
\n
\n