Install Elgg on Ubuntu 18.04

Updated on July 25, 2024
Install Elgg on Ubuntu 18.04 header image

Elgg is an open source social networking engine that allows the creation of social environments such as campus social networks and internal collaborative platforms for organizations. Elgg offers a number of social networking features including microblogging, messaging, file-sharing and groups. This tutorial will guide you through the process of installing Elgg on a Ubuntu 18.04 VPS.

##Prerequisites

  • A fresh Vultr Cloud Compute instance with Ubuntu 18.04 and root access.

##Step 1: Install Apache, MySQL, and PHP Elgg requires MySQL, PHP, and a web server. Before you can install Elgg, you will need to install the Apache web server, MySQL, and PHP.

Update the repository list.

apt-get update

Install the Apache web server.

apt-get install apache2 -y

Install MySQL.

apt-get install mysql-server -y

Complete the MySQL installation by executing the following command.

/usr/bin/mysql_secure_installation

During the installation, you will be asked to enter a root password. Enter a secure password. This will be the MySQL root password.

Would you like to setup VALIDATE PASSWORD plugin? [Y/N] N
New password: password
Re-enter new password: password
Remove anonymous users? [Y/N] Y
Disallow root login remotely? [Y/N] Y
Remove test database and access to it? [Y/N] Y
Reload privilege tables now? [Y/N] Y

Install PHP 7.2, as well as the PHP modules required by Elgg.

apt-get install php7.2 libapache2-mod-php7.2 php7.2-common php7.2-sqlite3 php7.2-curl php7.2-intl php7.2-mbstring php7.2-xmlrpc php7.2-mysql php7.2-gd php7.2-xml php7.2-cli php7.2-zip -y

##Step 2: Create a MySQL database for Elgg Elgg will require a MySQL database. Log into the MySQL console.

mysql -u root -p

When prompted for a password, enter the MySQL root password you set in step 1. Once you are logged in to the MySQL console, create a new database.

CREATE DATABASE elgg;

Create a new MySQL user and grant it privileges to the newly created database. You can replace username and password with the username and password of your choice.

GRANT ALL PRIVILEGES on elgg.* to 'username'@'localhost' identified by 'password';
FLUSH PRIVILEGES;

Exit the MySQL console.

exit

##Step 3: Download and Install Elgg Download the latest version of Elgg.

cd /var/www/html
rm -r index.html
wget https://elgg.org/download/elgg-2.3.7.zip

Unzip the downloaded archive and move the files to the root of the Apache web server.

apt install unzip
unzip elgg-2.3.7.zip
mv ./elgg-2.3.7/* . && rm elgg-2.3.7.zip && rm -r elgg-2.3.7

Create a data directory for Elgg.

sudo mkdir -p /var/www/html/data

Set the appropriate file permissions.

sudo chown -R www-data:www-data /var/www/html/
sudo chmod -R 755 /var/www/html/

##Step 4: Configure Apache for Elgg Elgg requires the Apache rewrite module. Enable the Apache rewrite module.

sudo a2enmod rewrite

Create an Apache configuration file for the Elgg installation.

sudo nano /etc/apache2/sites-available/elgg.conf

Paste the following snippet to the file, replacing example.com with your own domain name.

<VirtualHost *:80>
     DocumentRoot /var/www/html/
     ServerName example.com
     <Directory /var/www/html/>
          Options FollowSymlinks
          AllowOverride All
          Require all granted
     </Directory>
     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Enable the configuration and restart the Apache server.

 sudo a2ensite elgg.conf
 sudo systemctl restart apache2.service

##Step 5: Complete the Elgg Installation At this point, you can proceed to the Elgg browser installer to finish the installation. Open a browser window on your computer and navigate to your domain name. This will launch the Elgg browser installer. Proceed through the installer to the Database Installation step. Here, enter the credentials of the MySQL database you created in Step 2 and proceed to the next step.

On the next step, enter a site name and email address of your choice. In the Site URL field, enter your domain name. In the Data Directory field, enter /var/www/html/data and proceed to the next step.

Next, enter the administrator credentials of your choice and press Next. At this point the installation is complete.

To log into the administrator panel, navigate to the following URL.

http://{your-domain-name}/admin

You have successfully installed Elgg on a Ubuntu 18.04 VPS and can begin setting up your own social network.