Actions

Difference between revisions of "System Administrator's Guide/Installing Mahara/How to install Mahara in Ubuntu"

From Mahara Wiki

< System Administrator's Guide‎ | Installing Mahara
 
(13 intermediate revisions by 3 users not shown)
Line 1: Line 1:
If you are unfamiliar with Linux in general, and Debian-based distributions in particular, this guide will show you how to proceed, in addition to the "Installing Mahara" document.
+
If you are unfamiliar with Linux in general, and Debian-based distributions in particular, this guide will show you how to proceed.
  
This guide is just for installing a development site of Mahara as a localhost. For a production site, you would read the complete "[https://help.ubuntu.com/8.04/serverguide/C/index.html Ubuntu Server Guide]"  documentation.
+
This guide is just for installing a development site of Mahara as a localhost. For a production site, you would read helpful documentation from [[https://ubuntu.com/tutorials|Ubuntu tutorials]] for best practices.
  
During the installation process of Ubuntu 9.04, you should have had the option of installing a lamp server for local web development, but if not, the instructions are pretty simple. From the console, just type:
+
These instructions assume that you're running a fresh installation of an in support version of Ubuntu or similar.
  
  sudo apt-get install apache2 php5 mysql-server-5.0 phpmyadmin
+
== Install Required Packages ==
 
  
Hopefully, this will install all the dependencies we need. Phpmyadmin is not strictly needed to run your Mahara development site, but will allow you to check the database structure of Mahara. you can launch phpmyadmin by typing in your browser: localhost/phpmyadmin.
+
To install a site using apache2 webserver and postgresql database server
  
After we are sure that we have a lamp server platform installed, just follow the instructions provided in the "[[System Administrator's Guide/Installing Mahara|Installing Mahara]]" main document to unzip and install the Mahara folders.  As we are using MySQL as database, you can create the Mahara database directly in phpmyadmin. Remember to choose "utf8_general_ci" as a codification standard.
+
sudo apt-get install make curl wget xvfb postgresql php7.4-common php-cli libapache2-mod-php7.4 php7.4-curl php7.4-gd php-json php-ldap php-pgsql php-xmlrpc php-zip php-xml php7.4-pgsql php7.4-xml php7.4-xmlrpc php7.4-mbstring
  
The next step is to add your Mahara site as a new virtual hosts. There are many ways of doing so. This way will allow you to practice some Ubuntu commands (but if you are really desperate for time, there is a fastest way at the end of the explanation):
+
Note on php versions: At the time of writing (Nov 2020), php 7.4 has a year of active development remaining, and we are expecting the release of php 8.0 sometime soon. Php 7.4 is currently the recommended version to install. Sometimes there is a generic package _and_ a version-specific package to be installed. [PHP supported versions](https://www.php.net/supported-versions.php)
 +
 
 +
This should install all the dependencies we need.
 +
 
 +
If you are wanting to install using mysql version 8.0 then you will need to install the following:
 +
 
 +
sudo apt-get install mysql php7.4-mysql
 +
 
 +
And do the following step: [[Developer_Area/Developer_Environment#Using_MySql8|Using MySql 8]]]
 +
 
 +
After installing the packages, just follow the instructions provided in the "[[System Administrator's Guide/Installing Mahara|Installing Mahara]]" main document to unzip and install the Mahara folders.
 +
 
 +
== Download and unpack Mahara ==
 +
 
 +
In this example, we install mahara to /var/www/[hostname], and store our data in /var/lib/sitedata/[hostname].
 +
 
 +
Where [hostname] is some identifying name for your site, eg my-site-production
 +
 
 +
First find the supported version you want to download, either from [[https://launchpad.net/mahara/+download|Mahara downloads]], for example the 21.04.1 release:
 +
 
 +
  cd /var/
 +
  mkdir www
 +
  cd /var/lib/
 +
  mkdir sitedata
 +
  cd /var/www
 +
  wget https://launchpad.net/mahara/21.04/21.04.1/+download/mahara-21.04.1.zip
 +
  unzip mahara-21.04.1.zip
 +
  rm mahara-21.04.1.zip
 +
  mv mahara-21.04.1 [hostname]
 +
 
 +
== Configure the Database ==
 +
 
 +
The easiest way to create the database if using postgres is via the postgres user.
 +
 
 +
First make the database user that will own the database, in this case 'maharauser'
 +
 
 +
sudo -u postgres createuser -P -D -R -S maharauser
 +
 
 +
You'll be prompted for a password. Enter a complex value for the password and write it down. (easiest to use pwgen to generate one for you)
 +
 
 +
Next create the database with the [hostname].
 +
 
 +
sudo -u postgres createdb -Omaharauser [hostname]
 +
 
 +
== Configure Apache2 ==
 +
 
 +
The next step is to add your Mahara site as a new virtual hosts. There are many ways of doing so but this is the most straight forward:
  
 
# Create a new file called "mahara.conf" (for instance) at /etc/apache2/sites-available.
 
# Create a new file called "mahara.conf" (for instance) at /etc/apache2/sites-available.
Line 21: Line 66:
 
(or alternatively "sudo nano /etc/apache2/sites-available").
 
(or alternatively "sudo nano /etc/apache2/sites-available").
  
3.It is in this file where we are going to copy and paste the "Virtual Host" bit in the main instructions that you don't know what to do with. You need to customize that file with the values for your installation, in my case:
+
The following is a very basic example of an Apache configuration for Mahara. You'll need to put this into the mahara.conf file you just opened
  
<br />         ServerName mahara.es <br />         DocumentRoot /home/mcgarcia/mahara<br /><br />         ErrorLog /var/log/apache2/mahara-1-2-alpha.error.log<br />         CustomLog /var/log/apache2/mahara-1-2-alpha.access.log combined<br />
 
  
One we have added a this new virtual host, we need to link it with the ''repertoir'' of  virtualhost that Apache looks, which is in the folder "sites-enabled". So we go to that folder and create the link to the new host:
+
    &lt;VirtualHost *:80&gt;
 +
        ServerName [hostname]
 +
        DocumentRoot /var/www/[hostname]/htdocs
  
$cd /etc/apache2/sites-enabled/
+
        &lt;Directory /var/www/[hostname]/htdocs/&gt;
+
            Options Indexes FollowSymLinks MultiViews
  $sudo ln -s /etc/apache2/sites-available/mahara.conf mahara conf
+
            Require all granted
 +
        &lt;/Directory&gt;
  
And here comes the fastest way of enabling a new virtual host, just typing:
+
        ErrorLog /var/log/apache2/[hostname]-error.log
 +
        CustomLog /var/log/apache2/[hostname]-access.log combined
 +
    &lt;/VirtualHost&gt;
  
sudo a2ensite mahara.conf
 
 
  
4. You need to add the domain that you have choosen for your servername as a localhost domain, by editing the /etc/hosts file:
+
We'll then need to enable the site. On Ubuntu, Apache comes with a suite of commands for doing this kind of thing. We'll use the Apache2 Enable Site command:
 +
 
 +
 
 +
  sudo a2ensite mahara.conf
 +
 
 +
== DNS/Friendly Name ==
 +
 
 +
Depending on what you chose as your host name, you may need to add a DNS entry, or a line to the /etc/hosts file.
 +
 
 +
In this example, I'm running mahara on my local system for development/demonstration purposes. I don't have proper DNS available so I'm adding my mahara.local domain.
  
 
   sudo gedit /etc/hosts
 
   sudo gedit /etc/hosts
  
In that file, make sure that you got the line:
 
  
127.0.0.1  localhost  yourmaharadomain (in my case: mahara.es)
+
And add:
  
which, hopefully, will tell Ubuntu: don't go online everytime that I type that domain in my browser, as it corresponds to a localhost address).
+
127.0.0.1 [hostname]
  
5.  Then,  restart (or reload) Apache:
+
== Mahara Configuration ==
  
sudo /etc/init.d/apache2 restart
+
The next step is to create the config.php from the config-dist.php. This step is pretty well explain at the "[[System Administrator's Guide/Installing Mahara|Mahara Configuration]]", but essentialy we'll
  
The next step is to create the config.php from the config-dist.php. This step is pretty well explain at the "[[System Administrator's Guide/Installing Mahara|Mahara Configuration]]" secction of the installation guide, so we are not going to repeat it here. If it is of any help, here is how I configured my paths to the wwwroot and the dataroot:
+
  cd /var/www/[hostname]/htdocs
 +
  sudo cp config-dist.php config.php
 +
  sudo gedit config.php
  
$cfg-&gt;wwwroot = 'http://mahara.es/';
+
The key items to set are:
 +
* $cfg-&gt;wwwroot
 +
* $cfg-&gt;dataroot
 +
* $cfg-&gt;dbname
 +
* $cfg-&gt;dbuser
 +
* $cfg-&gt;dbpass
  
$cfg-&gt;dataroot = '/home/mcgarcia/maharadata';
+
If you've followed the steps so far, the following should work
  
Even for a development site, you need to make sure that the dataroot folder-maharadata-is writable for webserver user. If not, Mahara will tell you.
+
  &lt;?php
 +
  $cfg = new stdClass();
 +
  $cfg-&gt;dataroot = '/var/lib/sitedata/[hostname]';
 +
  $cfg-&gt;dbname = '[hostname]';
 +
  $cfg-&gt;dbuser = 'maharauser';
 +
  $cfg-&gt;dbpass = '[password]';
  
There is a very good-and short-[http://catcode.com/teachmod/  tutorial ] about how to change permissions and groups of users in Ubuntu by using the chmod command. It only takes 10 minutes to read it and it really gives you a good insight.
+
We'll need to make sure that the web server can write to the data directory (dataroot). To do this, we'll change who owns the directory with the chown command.
 +
Apache2 typically runs as the user 'www-data' on Debian and Ubuntu:
  
Once the dataroot folder permissions have been set up correctly, we are going to launch the installer by going to the web browser and typing the url of virtual host.
+
  sudo chown -R www-data:www-data /var/lib/sitedata/[hostname]
  
It looks like... it is working? Then, Mahara tells you that you need to install some php extensions. In may case, they were the gd and curl extensions, so I typed from console:
+
There is a very good-and short-[http://catcode.com/teachmod/  tutorial ] about how to change permissions and groups of users in Ubuntu by using the chmod command. It only takes 10 minutes to read it and it really gives you a good insight.
  
  sudo apt-get install php5-gd
+
== Install Mahara ==
 
  sudo apt-get install php5-curl
 
  
and don't forget to reload apache after that.
+
You should now be ready to actually install Mahara. Open your browser of choice, and visit the site (e.g. http://[hostname])
  
Once all the required extensions have been installed, Mahara will start installing the core components.
+
After checking you're ready to proceed, Mahara will install and ask for an e-mail address and password for your admin user.

Latest revision as of 14:36, 2 July 2021

If you are unfamiliar with Linux in general, and Debian-based distributions in particular, this guide will show you how to proceed.

This guide is just for installing a development site of Mahara as a localhost. For a production site, you would read helpful documentation from [tutorials] for best practices.

These instructions assume that you're running a fresh installation of an in support version of Ubuntu or similar.

Install Required Packages

To install a site using apache2 webserver and postgresql database server

sudo apt-get install make curl wget xvfb postgresql php7.4-common php-cli libapache2-mod-php7.4 php7.4-curl php7.4-gd php-json php-ldap php-pgsql php-xmlrpc php-zip php-xml php7.4-pgsql php7.4-xml php7.4-xmlrpc php7.4-mbstring

Note on php versions: At the time of writing (Nov 2020), php 7.4 has a year of active development remaining, and we are expecting the release of php 8.0 sometime soon. Php 7.4 is currently the recommended version to install. Sometimes there is a generic package _and_ a version-specific package to be installed. [PHP supported versions](https://www.php.net/supported-versions.php)

This should install all the dependencies we need.

If you are wanting to install using mysql version 8.0 then you will need to install the following:

sudo apt-get install mysql php7.4-mysql

And do the following step: Using MySql 8]

After installing the packages, just follow the instructions provided in the "Installing Mahara" main document to unzip and install the Mahara folders.

Download and unpack Mahara

In this example, we install mahara to /var/www/[hostname], and store our data in /var/lib/sitedata/[hostname].

Where [hostname] is some identifying name for your site, eg my-site-production

First find the supported version you want to download, either from [downloads], for example the 21.04.1 release:

 cd /var/
 mkdir www
 cd /var/lib/
 mkdir sitedata
 cd /var/www
 wget https://launchpad.net/mahara/21.04/21.04.1/+download/mahara-21.04.1.zip
 unzip mahara-21.04.1.zip
 rm mahara-21.04.1.zip
 mv mahara-21.04.1 [hostname]

Configure the Database

The easiest way to create the database if using postgres is via the postgres user.

First make the database user that will own the database, in this case 'maharauser'

sudo -u postgres createuser -P -D -R -S maharauser

You'll be prompted for a password. Enter a complex value for the password and write it down. (easiest to use pwgen to generate one for you)

Next create the database with the [hostname].

sudo -u postgres createdb -Omaharauser [hostname]

Configure Apache2

The next step is to add your Mahara site as a new virtual hosts. There are many ways of doing so but this is the most straight forward:

  1. Create a new file called "mahara.conf" (for instance) at /etc/apache2/sites-available.
  2. You need to edit that file by typing from the console:
  sudo gedit /etc/apache2/sites-available/mahara.conf

(or alternatively "sudo nano /etc/apache2/sites-available").

The following is a very basic example of an Apache configuration for Mahara. You'll need to put this into the mahara.conf file you just opened


   <VirtualHost *:80>
       ServerName [hostname]
       DocumentRoot /var/www/[hostname]/htdocs
       <Directory /var/www/[hostname]/htdocs/>
           Options Indexes FollowSymLinks MultiViews
           Require all granted
       </Directory>
       ErrorLog /var/log/apache2/[hostname]-error.log
       CustomLog /var/log/apache2/[hostname]-access.log combined
   </VirtualHost>


We'll then need to enable the site. On Ubuntu, Apache comes with a suite of commands for doing this kind of thing. We'll use the Apache2 Enable Site command:


 sudo a2ensite mahara.conf

DNS/Friendly Name

Depending on what you chose as your host name, you may need to add a DNS entry, or a line to the /etc/hosts file.

In this example, I'm running mahara on my local system for development/demonstration purposes. I don't have proper DNS available so I'm adding my mahara.local domain.

 sudo gedit /etc/hosts


And add:

127.0.0.1 [hostname]

Mahara Configuration

The next step is to create the config.php from the config-dist.php. This step is pretty well explain at the "Mahara Configuration", but essentialy we'll

 cd /var/www/[hostname]/htdocs
 sudo cp config-dist.php config.php
 sudo gedit config.php

The key items to set are:

  • $cfg->wwwroot
  • $cfg->dataroot
  • $cfg->dbname
  • $cfg->dbuser
  • $cfg->dbpass

If you've followed the steps so far, the following should work

 <?php
 $cfg = new stdClass();
 $cfg->dataroot = '/var/lib/sitedata/[hostname]';
 $cfg->dbname = '[hostname]';
 $cfg->dbuser = 'maharauser';
 $cfg->dbpass = '[password]';

We'll need to make sure that the web server can write to the data directory (dataroot). To do this, we'll change who owns the directory with the chown command. Apache2 typically runs as the user 'www-data' on Debian and Ubuntu:

 sudo chown -R www-data:www-data /var/lib/sitedata/[hostname]

There is a very good-and short-tutorial  about how to change permissions and groups of users in Ubuntu by using the chmod command. It only takes 10 minutes to read it and it really gives you a good insight.

Install Mahara

You should now be ready to actually install Mahara. Open your browser of choice, and visit the site (e.g. http://[hostname])

After checking you're ready to proceed, Mahara will install and ask for an e-mail address and password for your admin user.