Note: You are currently viewing documentation for Moodle 4.0. Up-to-date documentation for the latest stable version of Moodle may be available here: Installing Moodle on Debian based distributions.

Installing Moodle on Debian based distributions: Difference between revisions

From MoodleDocs
No edit summary
m (clean up)
 
(13 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==Installing Moodle as a Debian package==
==Installing Moodle as a Debian package==


Moodle used to be included as a Debian package.  However, it has not been included in recent releasesThere is talk of it being included again in the Jesse release but now, follow the instructions below to install Moodle on Debian.
Moodle used to be included as a Debian package.  It is not recommended to install using any kind of installer with MoodleIn the long run you will be much better to install manually (or using git) so that the code is original without any alteration.


==Installing moodle from .tgz(.tar.gz) or .zip file==
==Installing moodle from .tgz(.tar.gz) or .zip file==
Line 18: Line 18:
For installation of the necessary packages the easiest option to use apt-get through the command line interface.  Debian has easy access to a Root Terminal
For installation of the necessary packages the easiest option to use apt-get through the command line interface.  Debian has easy access to a Root Terminal


Use the following command to install apache2, php5 and mysql
Use the following command to install apache2, php5 and mysql (Note: Debian is now shipping with MariaDB as default database server - I have included instructions on how to install MySQL community edition instead.)
MySQL Server Package install:
<code>wget https://dev.mysql.com/get/mysql-apt-config_0.8.6-1_all.deb
mysql-apt-config_0.8.6-1_all.deb
apt-get install gdebi-core
gdebi mysql-apt-config_0.8.6-1_all.deb</code>


apt-get install apache2 php5 mysql-server php5-mysql libapache2-mod-php5 php5-gd php5-curl php5-xmlrpc php5-intl  
Update Repositories:
<code>apt-get update</code>
 
Install LAMP:
<code>apt-get install apache2 php7.1 mysql-server php7.1-mysql libapache2-mod-php7.1 php7.1-gd php7.1-curl php7.1-xmlrpc php7.1-intl php7.1-zip php7.1-mbstring </code>


The mentioned packages are installed along with the dependencies depending on what was already installed on your Debian system.
The mentioned packages are installed along with the dependencies depending on what was already installed on your Debian system.
Line 29: Line 38:
  gedit /etc/apache2/apache2.conf
  gedit /etc/apache2/apache2.conf
or
or
nano /etc/apache2/apache2.conf
<pre>nano /etc/apache2/apache2.conf</pre>
However, for a basic install, you should not need to mess with this file.
However, for a basic install, you should not need to mess with this file.


Now we must make a few changes in the php5 configuration file. Open it using
Now we must make a few changes in the php7.1 configuration file. Open it using


  gedit /etc/php5/apache2/php.ini
  gedit /etc/php/7.1/apache2/php.ini
or
or
nano /etc/php5/apache2/php.ini
<pre>nano /etc/php/7.1/apache2/php.ini</pre>


add the entries  
add the entries  
  extension=mysql.so  
  extension=mysql.so  
  extension=gd.so
  extension=gd.so
Line 55: Line 64:
You can restart apache 2 by  
You can restart apache 2 by  
  /etc/init.d/apache2 restart
  /etc/init.d/apache2 restart
or
service apache2 restart


===Step 2: Setup MySQL Database===
===Step 2: Setup MySQL Database===
Line 71: Line 82:


Create the Moodle database
Create the Moodle database
  mysql> CREATE DATABASE moodle;
  mysql> CREATE DATABASE moodle CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
 
(this should set the database up correctly to work with Moodle)
Then ensure that the database is set to UTF8 which is required by later distributions of Moodle
mysql> ALTER DATABASE moodle charset=utf8;


Then exit the database
Then exit the database
Line 85: Line 94:
Download moodle from http://download.moodle.org/?lang=en.
Download moodle from http://download.moodle.org/?lang=en.


===Step 3: Unpack file===
===Step 4: Unpack file===
* For zip file, use '''unzip <your_file>'''. For tgz(tar.gz), use '''tar -zxvf <your-file>'''. You can also use any of the GUI front-ends such as file-roller or ark or just let Debian unzip it with Archive Manager. You will get a folder moodle (or moodle-2.8.1 or something similar).  It will probably be located in your Downloads folder unless you told the Archive Manager or the Download utility to save it somewhere else.  We will presume it is in your Download folder.
* For zip file, use '''unzip <your_file>'''. For tgz(tar.gz), use '''tar -zxvf <your-file>'''. You can also use any of the GUI front-ends such as file-roller or ark or just let Debian unzip it with Archive Manager. You will get a folder moodle (or moodle-2.8.1 or something similar).  It will probably be located in your Downloads folder unless you told the Archive Manager or the Download utility to save it somewhere else.  We will presume it is in your Download folder.


From terminal type
From terminal type
cd /home/YourUSERNAME/Downloads
<pre>cd /home/YourUSERNAME/Downloads</pre>
mv moodle /var/www
<pre>mv moodle /var/www</pre>


You can also copy instead of moving it in case you want a backup of the code on your machine.
You can also copy instead of moving it in case you want a backup of the code on your machine.
cp -R moodle /var/www
<pre>cp -R moodle /var/www</pre>


You will probably need to do this as root (no problem if you are using the Root Terminal!)
You will probably need to do this as root (no problem if you are using the Root Terminal!)


===Step 4: Create a data directory and set Moodle directory permissions===
===Step 5: Create a data directory and set Moodle directory permissions===
Switch to the correct directory
Switch to the correct directory
cd /var/www
<pre>cd /var/www</pre>


Create a directory for user and course files  
Create a directory for user and course files  
Line 108: Line 117:
  chown -R www-data:www-data moodle
  chown -R www-data:www-data moodle
  chown -R www-data:www-data moodledata
  chown -R www-data:www-data moodledata
chmod -R 755 moodle
<br><pre>chmod -R 755 moodle</pre><br>
chmod -R 755 moodledata
<pre>chmod -R 755 moodledata</pre>


On a production server, you may want to tighten up privileges.
On a production server, you may want to tighten up privileges.


===Step 5: Change Apache to use Moodle as the web site===
===Step 6: Change Apache to use Moodle as the web site===


Note that the server comes with Apache running and looking at the /var/www directory.  But there is nothing in that folder, so one just gets a redirect.  Edit as follows to have it point at Moodle instead:
Note that the server comes with Apache running and looking at the /var/www directory.  But there is nothing in that folder, so one just gets a redirect.  Edit as follows to have it point at Moodle instead:
Line 119: Line 128:
gedit /etc/apache2/sites-available/default
gedit /etc/apache2/sites-available/default
or
or
  nano /etc/apache2/sites-available/default
  <pre>nano /etc/apache2/sites-available/default</pre>


On about line 4, change DocumentRoot "/var/www" to
On about line 4, change DocumentRoot "/var/www/html" to


  DocumentRoot "/var/www/moodle"
  DocumentRoot "/var/www/moodle"


On about line 10, change <Directory "/var/www/"> to
On about line 10, change <Directory "/var/www/html/"> to


  <Directory "/var/www/moodle/">
  <Directory "/var/www/moodle/">
Line 136: Line 145:


  /etc/init.d/apache2 restart
  /etc/init.d/apache2 restart
*  
*


===Step 7: Finally install===
===Step 7: Finally install===
Line 142: Line 151:




===Setup Moodle===
===Step 8: Setup Moodle===


If you are only going to test Moodle on your internal network, just enter the local IP address as the web address.  You can find the local IP address under DHCP by typing
If you are only going to test Moodle on your internal network, just enter the local IP address as the web address.  You can find the local IP address under DHCP by typing
Line 165: Line 174:
Moodle needs a periodic call to do maintenance work like sending out emails, cleaning up the database, updating feeds, etc.  To run the cron every 10 minutes, do the following
Moodle needs a periodic call to do maintenance work like sending out emails, cleaning up the database, updating feeds, etc.  To run the cron every 10 minutes, do the following


crontab -u www-data -e
<pre>crontab -u www-data -e</pre>


Add this line and save.
Add this line and save.
*/10 * * * * /usr/bin/php /var/www/moodle/admin/cli/cron.php  >/dev/null
<pre>*/10 * * * * /usr/bin/php /var/www/moodle/admin/cli/cron.php  >/dev/null</pre>




Line 177: Line 186:




[[Category: Administrator]]
[[Category:Administrator]]
[[Category:Installation]]
[[Category:Installation]]


[[es:Instalando Moodle en distribuciones basadas en Debian]]
[[ja:Debian GNU/Linuxのインストール]]
[[ja:Debian GNU/Linuxのインストール]]
[[pl:Instalacja Moodle w Debianie]]
[[pl:Instalacja Moodle w Debianie]]

Latest revision as of 14:18, 20 May 2022

Installing Moodle as a Debian package

Moodle used to be included as a Debian package. It is not recommended to install using any kind of installer with Moodle. In the long run you will be much better to install manually (or using git) so that the code is original without any alteration.

Installing moodle from .tgz(.tar.gz) or .zip file

Step 1: Install required packages

After installing your Debian distro, install these packages (if you've not already done so). See Installing Apache, MySQL and PHP or refer to the respective user manuals. Using apt-get, aptitude or synaptic you can install these very easily.

  • Web Server (Apache highly recommended)
  • Database Server (MySQL or PostgreSQL recommended)
  • PHP, PHP-MySQL mod (or mod for your database)
  • Various PHP modules necessary for Moodle

LAMP in Debian

Setting up a LAMP in Debian is very easy. Once you get used to Debian administration including installation and configuration are much simpler compared to other linux distros. The following describes how to install apache, php and mysql on the Debian distribution.

For installation of the necessary packages the easiest option to use apt-get through the command line interface. Debian has easy access to a Root Terminal

Use the following command to install apache2, php5 and mysql (Note: Debian is now shipping with MariaDB as default database server - I have included instructions on how to install MySQL community edition instead.) MySQL Server Package install: wget https://dev.mysql.com/get/mysql-apt-config_0.8.6-1_all.deb mysql-apt-config_0.8.6-1_all.deb apt-get install gdebi-core gdebi mysql-apt-config_0.8.6-1_all.deb

Update Repositories: apt-get update

Install LAMP: apt-get install apache2 php7.1 mysql-server php7.1-mysql libapache2-mod-php7.1 php7.1-gd php7.1-curl php7.1-xmlrpc php7.1-intl php7.1-zip php7.1-mbstring

The mentioned packages are installed along with the dependencies depending on what was already installed on your Debian system.

Now you may fire up a browser and type localhost to check whether the apache2 default page is shown,

If you are familiar with apache settings, you can edit the apache configuration files using the text editor gedit or nano by typing:

gedit /etc/apache2/apache2.conf

or

nano /etc/apache2/apache2.conf

However, for a basic install, you should not need to mess with this file.

Now we must make a few changes in the php7.1 configuration file. Open it using

gedit /etc/php/7.1/apache2/php.ini

or

nano /etc/php/7.1/apache2/php.ini

add the entries

extension=mysql.so 
extension=gd.so

Sometimes these entries are provided as example lines being commented out . You can remove the commenting to activate the entries. Then make the following changes (adjust to your preference) This will allocated more memory and allow files to be uploaded up to 80MB. This should be enough for most multi-media files. Hard drive space is cheap and the default is only 2MB. It is recommended that you change the settings to the following values:

memory_limit = 40M
post_max_size = 80M
upload_max_filesize = 80M

To test the php installation, you can create a text file named phpinfo.php with the contents <?phpinfo()?> and save it at /var/www. Restart apache with the command below. Now access this file through the browser localhost/phpinfo to check the installation of php.

You can restart apache 2 by

/etc/init.d/apache2 restart

or service apache2 restart

Step 2: Setup MySQL Database

Set a secure root password for the database (you might have already done this in the initial install process)

mysqladmin -u root password "mySecurePassword"

Note that on a secure production server, you will want to create a different user than root to access the database.

Now log in

mysql -u root -p

Enter your password

Create the Moodle database

mysql> CREATE DATABASE moodle CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

(this should set the database up correctly to work with Moodle)

Then exit the database

mysql> exit;

You can restart mysql by

/etc/init.d/mysql restart

Step 3: Download moodle

Download moodle from http://download.moodle.org/?lang=en.

Step 4: Unpack file

  • For zip file, use unzip <your_file>. For tgz(tar.gz), use tar -zxvf <your-file>. You can also use any of the GUI front-ends such as file-roller or ark or just let Debian unzip it with Archive Manager. You will get a folder moodle (or moodle-2.8.1 or something similar). It will probably be located in your Downloads folder unless you told the Archive Manager or the Download utility to save it somewhere else. We will presume it is in your Download folder.

From terminal type

cd /home/YourUSERNAME/Downloads
mv moodle /var/www

You can also copy instead of moving it in case you want a backup of the code on your machine.

cp -R moodle /var/www

You will probably need to do this as root (no problem if you are using the Root Terminal!)

Step 5: Create a data directory and set Moodle directory permissions

Switch to the correct directory

cd /var/www

Create a directory for user and course files

mkdir moodledata

Set ownership and permissions so that Apache can access the files

chown -R www-data:www-data moodle
chown -R www-data:www-data moodledata


chmod -R 755 moodle


chmod -R 755 moodledata

On a production server, you may want to tighten up privileges.

Step 6: Change Apache to use Moodle as the web site

Note that the server comes with Apache running and looking at the /var/www directory. But there is nothing in that folder, so one just gets a redirect. Edit as follows to have it point at Moodle instead:

gedit /etc/apache2/sites-available/default or

nano /etc/apache2/sites-available/default

On about line 4, change DocumentRoot "/var/www/html" to

DocumentRoot "/var/www/moodle"

On about line 10, change <Directory "/var/www/html/"> to

<Directory "/var/www/moodle/">

Around line 17, comment out the line for the default page:

# RedirectMatch ^/$ /apache2-default/

You can change other values like ServerAdmin if appropriate. For all changes, you should restart Apache for the new settings to take effect.

/etc/init.d/apache2 restart

Step 7: Finally install


Step 8: Setup Moodle

If you are only going to test Moodle on your internal network, just enter the local IP address as the web address. You can find the local IP address under DHCP by typing

ifconfig eth0


If you have a web address that points to your server, use that instead.

From a browser on another machine, enter

http:// ----- your web address -----
  • For the database user, enter root
  • For Password, enter the password for the database that you created earlier

Continue through the dialogs until installed.

Install cron

Moodle needs a periodic call to do maintenance work like sending out emails, cleaning up the database, updating feeds, etc. To run the cron every 10 minutes, do the following

crontab -u www-data -e

Add this line and save.

*/10 * * * * /usr/bin/php /var/www/moodle/admin/cli/cron.php  >/dev/null


Use CNTL-X to save