24th April, 2017 | Tutorials |

How to Install Elgg on CentOS 7

Want your very own server? Get our 1GB memory, Xeon V4, 25GB SSD VPS for £10.00 / month.

Get a Cloud Server

Elgg is a free and open source social networking platform. You can use Elgg to create a campus wide social networking site for your college or school. You can also use Elgg to create an internal collaborative platform for your organization. Elgg is written in PHP and uses MySQL to store its data.

In this tutorial we will be installing Elgg on CentOS 7 server.


Elgg does not require any special hardware requirements. It can be installed on servers with a small amount of RAM. All the required dependencies will be installed throughout the tutorial. You will need a minimal installation of CentOS 7 with root access on it. If you are logged in as a non-root user, you can run sudo -i to switch to root user.

Installing Elgg

Before installing any package it is recommended that you update the packages and repository using the following command.

yum -y update

Now install Apache, Git and MariaDB, which is a fork of MySQL using following command.

yum -y install httpd mariadb-server mariadb git

Elgg requires PHP 5.6 or higher. In this tutorial we will install PHP 7 to obtain high performance. Install EPEL repository using following commands.

yum -y install epel-release yum -y update

Now install the Webtatic repository using the following commands.

rpm -Uvh yum -y update

To install PHP 7.1 and all the required PHP modules, run the following command.

yum -y install php71w php71w-openssl php71w-dom php71w-mysql php71w-cli php71w-mbstring php71w-gd

Once you have PHP installed, you can check the version of PHP using the following command.

php -v You should get output similar to this.
[root@liptan-pc ~]# php -v
PHP 7.1.3 (cli) (built: Mar 19 2017 15:31:52) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies

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

systemctl start httpd systemctl enable httpd

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

systemctl start mariadb systemctl enable mariadb

Now run the following commands to secure your MySQL or MariaDB installation.


It will run a small script which asks you to provide the root password for MariaDB. As we have just installed MariaDB, the root password is not set, just press enter to proceed further. Set a root password for MySQL root user and answer y for all other questions asked.

Now you will need to create a database to store Elgg data.

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

mysql -u root -p

This will prompt you for the password, provide the root password of MySQL which you have set earlier. Now run the following query to create a new database for your Elgg installation.


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

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

Replace StrongPassword with a strong password. Now provide the appropriate privileges to your database user over the database you have created. Run the following command.

GRANT ALL PRIVILEGES ON elgg_data.* TO 'elgg_user'@'localhost';

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


Exit from MySQL prompt using exit command.

Elgg can be installed in two ways, either using composer or using the setup archive. In this tutorial both the methods are explained.

Using Composer

If you want to use Composer to install Elgg, you will need to install Composer. Composer is a dependency manager for PHP.

curl -sS | php mv composer.phar /usr/bin/composer

Now switch to the webroot directory of Apache web server and download Elgg using following command.

cd /var/www composer global require "fxp/composer-asset-plugin:~1.1.4" composer create-project elgg/starter-project:dev-master elgg

Once the download finishes, go to the newly created Elgg directory and install the required Composer dependencies using the following commands.

cd elgg composer install && composer install

Elgg files are now downloaded, you can now continue the tutorial from disabling SELinux.

Using Setup Archive

To install Elgg using the setup archive, run the following command to download the archive.

cd /var/www wget -O

You can always check the Elgg download page to look for the link to the latest version of archive.

Now extract the archive using the following command.


If you do not have unzip installed, you can run yum -y install unzip. The above command will extract the archive to elgg-2.3.2 directory. Rename the directory using the following command.

mv elgg-* elgg

Now you will need to disable your SELinux. To temporary disable SELinux, 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, you will need to provide the ownership of the application to web server user using the following command.

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

You will also need to create a new directory to store Elgg site data. Run the following command to do so.

mkdir /var/www/elgg/data chown apache:apache /var/www/elgg/data

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

Now create a virtual host for the Elgg application. Run the following command to do so.

nano /etc/httpd/conf.d/

Paste the following lines into the file.

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

Replace with any domain or sub-domain 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 using your favorite web browser.

You will be welcomed by the following page.

HP_NO_IMG/data/uploads/users/5bc5f3e0-17df-4257-afd4-59fc57ecae4e/1924332846.png" alt="" />

Click Next to proceed further. In this interface, you will be shown the requirement analysis. If you have followed the tutorial correctly, then all the requirements will be satisfied.

HP_NO_IMG/data/uploads/users/5bc5f3e0-17df-4257-afd4-59fc57ecae4e/224226166.png" alt="" />

In next interface you will need to provide the database information. Fill out the information of database which we have created earlier.

HP_NO_IMG/data/uploads/users/5bc5f3e0-17df-4257-afd4-59fc57ecae4e/306971383.png" alt="" />

In next interface, you will need to provide the information of your site, like Site name, site email address and URL. Enter /var/www/elgg/data into data directory field.

HP_NO_IMG/data/uploads/users/5bc5f3e0-17df-4257-afd4-59fc57ecae4e/1626365272.png" alt="" />

Finally you will need to create the admin account. Fill out the information and click Next button.

HP_NO_IMG/data/uploads/users/5bc5f3e0-17df-4257-afd4-59fc57ecae4e/393065994.png" alt="" />

Elgg is now installed on your server. You will be automatically redirected to your site which will look like shown below.

HP_NO_IMG/data/uploads/users/5bc5f3e0-17df-4257-afd4-59fc57ecae4e/1579463214.png" alt="" />


In this tutorial we have learned to install Elgg Social Networking Platform on CentOS 7. You can now successfully deploy the application to create a social networking or collaboration site for your education institute or organization.

Want your very own server? Get our 1GB memory, Xeon V4, 25GB SSD VPS for £10.00 / month.

Get a Cloud Server