Difference between revisions of "Installation on Ubuntu using Git"

Jump to: navigation, search

Note: You are currently viewing documentation for Moodle 3.1. Up-to-date documentation for the latest stable version of Moodle is probably available here: Installation on Ubuntu using Git.

(and finally)
(added line apt-get install php5-json to pass beyond blank screen in Ubuntu desktop 13.10)
 
(15 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 +
{{Installing Moodle}}
 
==Introduction==
 
==Introduction==
  
This is probably an unrealistic scenario but it stemmed from a question asked in the forums and the results might be useful to others. This was done on Mythbuntu 10.10. Mythbuntu is one of the Ubuntu derivatives, in this case providing a Linux based TV package. It comes with PHP, Apache and MySQL installed having its own web-based controller. 
+
This page gives the basic steps to install Moodle on Ubuntu using Moodle code from Git. This is generally a better idea than using the Ubuntu '.deb' package.
  
 
There was no intention to provide a fully secured production server. This just gets basic Moodle working on 'localhost'.
 
There was no intention to provide a fully secured production server. This just gets basic Moodle working on 'localhost'.
  
==Install Mythbuntu==
+
This should work on either Ubuntu Desktop or Server edition.
  
- Install [http://www.mythbuntu.org/ Mythbuntu] using (if in doubt) default settings
+
==Install Ubuntu==
- Log in and exit MythTV application (using Escape Key)
+
 
- Run Firefox and ensure that 'mythweb' is running at localhost (proving the web server is running)
+
* Install [http://ubuntu.org/ Ubuntu Desktop] or [http://www.ubuntu.com/download/server/download Ubuntu Server] using (if in doubt) default settings
  
 
==Basic Setup==
 
==Basic Setup==
  
- Open a terminal window (from Applications>Accessories)
+
* Open a terminal window (from Applications>Accessories) on Desktop or log into the terminal on Server.
- become root (and stay there right through this), install some additional software (git and php extras Moodle needs):
+
* become root (and stay there right through this), install some additional software (git and php extras Moodle needs):
 
<pre>
 
<pre>
 
sudo su  (you will need to enter your password)
 
sudo su  (you will need to enter your password)
Line 20: Line 21:
 
apt-get install git git-core git-doc
 
apt-get install git git-core git-doc
 
apt-get install php5-gd php5-curl php5-intl php5-xmlrpc
 
apt-get install php5-gd php5-curl php5-intl php5-xmlrpc
 +
apt-get install php5 mysql-server mysql-client apache2  php5-mysql
 +
apt-get install php5-json
 
</pre>
 
</pre>
 +
 +
* (on Desktop) open a web browser and go to http://localhost/ and make sure you see 'It works!'.
 +
* (on Server) open a web browser on a remote machine and go to http://name.or.ip.of.server/ and make sure you see 'It works!'.
  
 
==Install Moodle code==
 
==Install Moodle code==
  
We're going to use Git to pull the latest code. You could just download it, but this is more fun! The chmod is so the installer can write the config file.
+
We're going to use Git to pull the latest code. You could just download it, but this is more fun! The checkout switches to the latest (weekly) of the 2.6 branch. The chmod (temporarily) allows the installation script to write the config file. Still as superuser ('sudo su' from before):
  
 
<pre>
 
<pre>
 
cd /var/www
 
cd /var/www
git clone git://git.moodle.org/moodle.git
+
git clone https://github.com/moodle/moodle.git
chmod 0777 moodle
+
cd moodle
 +
git checkout -t origin/MOODLE_26_STABLE
 +
chmod 0777 /var/www/moodle
 
</pre>
 
</pre>
  
Line 36: Line 44:
 
==Create the data area==
 
==Create the data area==
  
You can create this where you like (more or less) but I will do...
+
You can create this where you like (more or less) but I will do (assuming you are still superuser)...
  
 
<pre>
 
<pre>
Line 47: Line 55:
 
==Create the database==
 
==Create the database==
  
You will need the root database password. Unless you have changed it, this is same as your login password
+
You will need the root database password. Unless you have changed it, this is same as your login password (or whatever you set up when you installed MySQL above).
  
 
<pre>
 
<pre>
 
mysql -u root -p
 
mysql -u root -p
 +
(asks for password here)
 
mysql> create database moodle default character set utf8;
 
mysql> create database moodle default character set utf8;
 
mysql> grant all on moodle.* to moodleuser@localhost identified by 'mypassword';
 
mysql> grant all on moodle.* to moodleuser@localhost identified by 'mypassword';
Line 58: Line 67:
 
'''Notes:'''
 
'''Notes:'''
 
* don't type 'mysql>', that's just the prompt from the mysql client.
 
* don't type 'mysql>', that's just the prompt from the mysql client.
 +
* The ''grant'' command creates the MySQL account 'moodleuser' with the supplied password and gives it rights to the moodle database all in one command.
 
* Set 'mypassword' to something you make up. This is the password for your moodle database
 
* Set 'mypassword' to something you make up. This is the password for your moodle database
 
* When you install moodle the database is called 'moodle', the database user 'moodleuser' and the password as above
 
* When you install moodle the database is called 'moodle', the database user 'moodleuser' and the password as above
Line 63: Line 73:
 
==Configure apache==
 
==Configure apache==
  
Apache is configured for mythweb so needs a small tweak to work:
+
The standard configuration of Apache on Ubuntu should work fine and will give you a Moodle URL of http://name.or.ip.of.server/moodle (or http://localhost/moodle).
 
 
<pre>
 
cd /etc/apache2/sites-enabled
 
</pre>
 
  
Use your favourite editor to edit the file  default-mythbuntu. After the closing </Directory> on (or about) line 15 add:
+
If you need other configurations or a different form of URL, now is the time to configure this. However, this is not covered here. There is lots of information online, although do note that the Ubuntu Apache configuration is rather different to the standard layout.
 
 
<pre>
 
    <Directory /var/www/moodle/>
 
        DirectoryIndex index.php
 
        order allow,deny
 
        allow from all
 
    </Directory>
 
</pre>
 
 
 
make sure you do not add any spaces in 'allow,deny'. Save and exit.
 
 
 
Restart Apache:
 
 
 
<pre>
 
/etc/init.d/apache2 restart
 
</pre>
 
 
 
(A force-reload will not be enough).  
 
  
 
==Install Moodle==
 
==Install Moodle==
Line 95: Line 83:
  
 
==and finally==
 
==and finally==
 +
 +
Don't skip this step. This secures the Moodle code, preventing it being overwritten by hackers.
  
 
<pre>
 
<pre>
Line 101: Line 91:
 
</pre>
 
</pre>
  
==a quick not on updating==
+
==Don't forget==
 +
 
 +
* Set up [[Cron]]
 +
* Check the [[Email settings]]
 +
 
 +
==a quick note on updating==
  
Because we installed using Git, updating Moodle becomes surprisingly simple. If it matters, do a backup first then:
+
Because we installed using Git, updating Moodle (on the same stable branch) becomes surprisingly simple. Using the repository we did gives you the latest weekly at any time. If it matters, do a backup first then:
  
 
<pre>
 
<pre>
Line 113: Line 108:
  
 
Then go to the Site administration > Notifications page in Moodle to complete the upgrade.
 
Then go to the Site administration > Notifications page in Moodle to complete the upgrade.
 +
 +
==Troubleshooting==
 +
 +
* If something goes wrong in the actual Moodle installation - switch on [[Debugging]]. You can create Moodle's config.php file by copying config-dist.php to config.php and editing it. It is very well documented by comments. Well down in the file you will find the options to turn on debugging. See [[Configuration file]]. If you create the file by hand, the installation will pick up from the correct place automatically.
 +
* Most errors will turn up in the web server logs. Always check there first - /var/log/apache2/errors.log
 +
* If you need to change things like file upload sizes you need to edit /etc/php5/apache2/php.ini and then restart the web server with 'sudo /etc/init.d/apache2 restart'
 +
 +
==See also==
 +
 +
* [https://help.ubuntu.com/community/Installation Installing Ubuntu]
 +
* [https://help.ubuntu.com/community/ApacheMySQLPHP Ubuntu LAMP/Apache documentation]

Latest revision as of 18:35, 20 February 2014

Introduction

This page gives the basic steps to install Moodle on Ubuntu using Moodle code from Git. This is generally a better idea than using the Ubuntu '.deb' package.

There was no intention to provide a fully secured production server. This just gets basic Moodle working on 'localhost'.

This should work on either Ubuntu Desktop or Server edition.

Install Ubuntu

Basic Setup

  • Open a terminal window (from Applications>Accessories) on Desktop or log into the terminal on Server.
  • become root (and stay there right through this), install some additional software (git and php extras Moodle needs):
sudo su  (you will need to enter your password)
apt-get update
apt-get install git git-core git-doc
apt-get install php5-gd php5-curl php5-intl php5-xmlrpc
apt-get install php5 mysql-server mysql-client apache2  php5-mysql
apt-get install php5-json

Install Moodle code

We're going to use Git to pull the latest code. You could just download it, but this is more fun! The checkout switches to the latest (weekly) of the 2.6 branch. The chmod (temporarily) allows the installation script to write the config file. Still as superuser ('sudo su' from before):

cd /var/www
git clone https://github.com/moodle/moodle.git
cd moodle
git checkout -t origin/MOODLE_26_STABLE
chmod 0777 /var/www/moodle
  • The moodle code location (for installation) is /var/www/moodle

Create the data area

You can create this where you like (more or less) but I will do (assuming you are still superuser)...

mkdir /var/moodledata
chmod 0777 /var/moodledata
  • The moodle data location (for installation) is /var/moodledata

Create the database

You will need the root database password. Unless you have changed it, this is same as your login password (or whatever you set up when you installed MySQL above).

mysql -u root -p
(asks for password here)
mysql> create database moodle default character set utf8;
mysql> grant all on moodle.* to moodleuser@localhost identified by 'mypassword';
mysql> exit

Notes:

  • don't type 'mysql>', that's just the prompt from the mysql client.
  • The grant command creates the MySQL account 'moodleuser' with the supplied password and gives it rights to the moodle database all in one command.
  • Set 'mypassword' to something you make up. This is the password for your moodle database
  • When you install moodle the database is called 'moodle', the database user 'moodleuser' and the password as above

Configure apache

The standard configuration of Apache on Ubuntu should work fine and will give you a Moodle URL of http://name.or.ip.of.server/moodle (or http://localhost/moodle).

If you need other configurations or a different form of URL, now is the time to configure this. However, this is not covered here. There is lots of information online, although do note that the Ubuntu Apache configuration is rather different to the standard layout.

Install Moodle

Open Firefox and go to address http://localhost/moodle You should be able to install Moodle using the information indicated above

and finally

Don't skip this step. This secures the Moodle code, preventing it being overwritten by hackers.

chmod 0755 /var/www/moodle
exit

Don't forget

a quick note on updating

Because we installed using Git, updating Moodle (on the same stable branch) becomes surprisingly simple. Using the repository we did gives you the latest weekly at any time. If it matters, do a backup first then:

sudo su
chmod /var/www/moodle
git pull
exit

Then go to the Site administration > Notifications page in Moodle to complete the upgrade.

Troubleshooting

  • If something goes wrong in the actual Moodle installation - switch on Debugging. You can create Moodle's config.php file by copying config-dist.php to config.php and editing it. It is very well documented by comments. Well down in the file you will find the options to turn on debugging. See Configuration file. If you create the file by hand, the installation will pick up from the correct place automatically.
  • Most errors will turn up in the web server logs. Always check there first - /var/log/apache2/errors.log
  • If you need to change things like file upload sizes you need to edit /etc/php5/apache2/php.ini and then restart the web server with 'sudo /etc/init.d/apache2 restart'

See also