How to Install Mahara ePortfolio System on CentOS 7

Mahara is an open source e-portfolio system. It can also be used as a social networking platform. Mahara is written in PHP and uses either PostgreSQL or MySQL database server to store its data. You can use Mahara to create your personalized multimedia portfolio and to collaborate with others.

In this tutorial, we will install Mahara on CentOS 7 server.


  • Minimal CentOS 7 server
  • Root privileges

Step 1 - Installing Apache

It is recommended to update the server before installing any package so that the existing packages and repositories are updated.

yum -y update

Once you have your system updated, you can proceed to install the Apache web server.

yum -y install httpd

Now start Apache web server and enable it to start at boot time using the following command.

systemctl start httpd

systemctl enable httpd

Step 2 - Installing PHP

Mahara supports all the version of PHP greater than 5.3. But in this tutorial, we will install PHP 7.1 as PHP v5.3 has reached the end of life. Installing the latest version of PHP will ensure the maximum security and performance of the application.

The default YUM repository of CentOS does not have PHP 7.1 included, hence you will need to add the Webtatic repository in your system. Install EPEL release:

yum -y install epel-release

yum -y update

Type the commands to install Webtatic repository.

rpm -Uvh

yum -y update

Type the following command to install PHP 7.1 along with all the required dependencies.

yum -y install php71w php71w-mysqli php71w-gd php71w-cli php71w-mcrypt php71w-mbstring php71w-dom

To check if PHP is installed successfully, you can run:

php -v

You should get output similar to this.

[root@liptan-pc ~]# php -v
PHP 7.1.6 (cli) (built: Jun 10 2017 07:28:42) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies

Now you will need to configure few configurations in PHP. Open the PHP configuration file, php.ini using your favourite text editor.

nano /etc/php.ini

Find the following line and Uncomment the line and set the timezone according to your region. For example:

; Defines the default timezone used by the date functions
date.timezone = Asia/Kolkata

Further, search for the following line:

;session.entropy_length = 32

Uncomment the line and search for the following line:

post_max_size = 8M

Change the value from 8M to 999M. Save the file and exit from the editor.

Step 3 - Installing MariaDB

MariaDB is a fork of MySQL database. To install MariaDB on your server, run:

yum -y install mariadb mariadb-server

Run the following commands to start MariaDB and enable it to start at boot time.

systemctl start mariadb

systemctl enable mariadb
Now run the following commands to secure your MariaDB installation.


The above command will run a script to secure fresh MariaDB installation. The script will ask for the existing root user password, we have just installed MariaDB, the root password is not set, just press enter to proceed further.

The script will ask you if you want to set a root password for your MariaDB installation, choose y and set a strong password for the installation. Most of the questions are self-explanatory and you should answer yes or y to all the questions. The output will look like shown below.

To create a database we will need to login to MySQL command line first. Run the following command for same.

mysql -u root -p

The above command will log in to MySQL shell of the root user, it will prompt for the password of the root user. Provide the password to log in. Now run the following query to create a new database for your Mahara installation.


The above query will create a new database named mahara_data. Make sure that you use semicolon at the end of each query as the query always ends with a semicolon.

To create a new database user, run the following query.

CREATE USER 'mahara_user'@'localhost' IDENTIFIED BY 'StrongPassword';

Now provide the all the privileges to your database user over the database you have created. Run the following command.

GRANT ALL PRIVILEGES ON mahara_data.* TO 'mahara_user'@'localhost';

Now run the following command to immediately apply the changes on the database privileges.


Exit from MySQL prompt using the following command.


Step 4 - Installing and Configuring Mahara

As we have all the dependencies ready, we can now download the install package from Mahara website.

cd /var/www


You can always find the link to the latest version of the application on Mahara download page. Extract the archive using the following command.

unzip mahara*.zip

If you do not have to unzip installed, you can run yum -y install unzip. Rename your Mahara folder using:

mv mahara-*/ mahara/

Create a new data directory to store Mahara session data by running:

mkdir /var/www/mahara/data

Copy the Mahara configuration file by running:

cp mahara/htdocs/config-dist.php mahara/htdocs/config.php

Open the file in nano editor by running:

nano mahara/htdocs/config.php

Now, find the following lines.

$cfg->dbtype   = 'postgresql';
$cfg->dbhost   = 'localhost';
$cfg->dbport   = null; // Change if you are using a non-standard port number for your database
$cfg->dbname   = '';
$cfg->dbuser   = '';
$cfg->dbpass   = '';

Change the above information according to the database you have created. In this case, the above lines should look like as shown below.

$cfg->dbtype   = 'mysql';
$cfg->dbhost   = 'localhost';
$cfg->dbport   = null; // Change if you are using a non-standard port number for your database
$cfg->dbname   = 'mahara_data';
$cfg->dbuser   = 'mahara_user';
$cfg->dbpass   = 'StrongPassword';

Now find the following line and change the path of data directory.

$cfg->dataroot = '/var/www/mahara/data';

Also provide a random string in the configuration below, it is used to encrypt the user data.

$cfg->passwordsaltmain = 'some random string here.';

Now change the URL secret to null so that you can run cron directly using the browser.

$cfg->urlsecret = null;

Save the file and exit from editor.

Step 5 - Configure Permissions and Firewall

Now you will need to provide the ownership of the application to web server user using the following command.

chown -R apache:apache /var/www/mahara

You may also need to allow HTTP traffic on port 80 through the firewall if you are running one. Run the following commands for same.

firewall-cmd --zone=public --permanent --add-service=http

firewall-cmd --reload

To temporary disable SELinux without restarting the server, run the following command.

setenforce 0

To completely disable the SELinux you will need to edit /etc/selinux/config file.

nano /etc/selinux/config

Find the following line:


Change it to:


Now create a virtual host for the Mahara application. Run the following command for same.

nano /etc/httpd/conf.d/

Paste the following lines into the file.

<VirtualHost *:80>
    DocumentRoot "/var/www/mahara/htdocs"
    <Directory "/var/www/mahara/htdocs">
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    ErrorLog "/var/log/httpd/"
    CustomLog "/var/log/httpd/" combined

Replace with any domain or subdomain you want to use to access the application. Save the file and exit from the editor. Run the following command to restart your Apache server.

systemctl restart httpd

Now complete the installation using a web browser, go to the following link.

You will be welcomed by the following page.

Click on Install Mahara button to proceed further.

On next interface, Mahara will write the database and will install the necessary modules to get you started. Once done, you can click Continue link to proceed further.

On next interface, you will be asked to set a password for Administrator dashboard.

Finally, you will be taken to administration dashboard, which will look like as shown below.


Installation of Mahara is now finished, you can use the Mahara to easily create a beautiful website for the personal or commercial purpose.

Share this page:

Suggested articles

0 Comment(s)

Add comment