Install Elgg on Debian 12

How to Install Elgg on Debian 12

Elgg is an open-source social networking platform that allows users to create and manage their own social networks and communities.

It provides a flexible architecture that allows developers to extend and customize its functionality according to their specific needs. Elgg also supports the creation of plugins and themes, enabling further customization and integration with other systems.

In this tutorial, we will show you how to install Elgg on Debian 12 OS.

Step 1: Update Operating System

Update your Debian 12 operating system to the latest version with the following command:

# apt update && apt upgrade

Step 2: Install Apache webserver

You can install it via apt package manager by executing the following command.

# apt install apache2

Verify the status of the Apache service using systemctl status command:

# systemctl status apache2

Output:

 apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; preset: enabled)
     Active: active (running)
       Docs: https://httpd.apache.org/docs/2.4/
   Main PID: 3682 (apache2)
      Tasks: 55 (limit: 2273)
     Memory: 8.6M
        CPU: 32ms
     CGroup: /system.slice/apache2.service
             ├─3682 /usr/sbin/apache2 -k start
             ├─3684 /usr/sbin/apache2 -k start
             └─3685 /usr/sbin/apache2 -k start

Step 3: Install PHP and PHP extensions for Elgg

To install PHP and additional PHP modules to support Elgg, run the following command:

# apt install php php-cli php-common libapache2-mod-php php-curl php-zip php-gd php-mysql php-xml php-mbstring php-xmlrpc php-intl

Verify if PHP is installed.

php -v
Output:
PHP 8.2.7 (cli) (built: Jun  9 2023 19:37:27) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.7, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.7, Copyright (c), by Zend Technologies

After installing all the packages, edit the php.ini file:

# nano /etc/php/8.2/apache2/php.ini

Change the following settings per your requirements:

max_execution_time = 300
memory_limit = 512M
post_max_size = 128M
upload_max_filesize = 128M
date.timezone = America/Chicago

To implement the changes, restart Apache webserver:

# systemctl restart apache2

Step 4: Install MariaDB and create a database

To install MariaDB run the following command:

# apt install mariadb-server mariadb-client

Verify the status of the MariaDB service using systemctl status command:

# systemctl status mariadb

Output:

 mariadb.service - MariaDB 10.11.3 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; preset: enabled)
     Active: active (running)
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
   Main PID: 16734 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 12 (limit: 2273)
     Memory: 203.0M
        CPU: 464ms
     CGroup: /system.slice/mariadb.service
             └─16734 /usr/sbin/mariadbd

By default, MariaDB is not hardened. You can secure MariaDB using the mysql_secure_installation script.

# mysql_secure_installation

Configure it like this:

- Enter current password for root (enter for none): Enter
- Switch to unix_socket authentication [Y/n] Y
- Change the root password? [Y/n] Y
- 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

Now run the command below to log in to the MariaDB shell.

# mysql -u root -p

Once you are logged in to your database server you need to create a database for the Elgg installation:

MariaDB [(none)]> CREATE DATABASE elgg;
MariaDB [(none)]> CREATE USER 'elgg'@'localhost' IDENTIFIED BY 'Str0ngPass2F';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON elgg. * TO 'elgg'@'localhost';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;

Step 5: Download Elgg

The latest version of Elgg is available to download from the official website. As of writing this tutorial, the latest version available is 5.0.1.

# wget https://elgg.org/download/elgg-5.0.1.zip

Then extract file into the folder /var/www/ with the following command:

# unzip elgg-5.0.1.zip -d /var/www/

Rename the extracted directory:

# mv /var/www/elgg-5.0.1 /var/www/elgg/

Create a data directory:

# mkdir /var/www/data/

Then enable permission for the Apache webserver user to access the files:

# chown -R www-data:www-data /var/www/data/
# chown -R www-data:www-data /var/www/elgg/

Step 6: Configure Apache for Elgg

Run the commands below to create a new VirtualHost file called elgg in the /etc/apache2/sites-available/ directory.

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

Paste the content as shown below:

 <VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot /var/www/elgg/
    
    ServerName your-domain.com
    ServerAlias www.your-domain.com

    <Directory /var/www/elgg/> 
        Options FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory> 

    ErrorLog /var/log/apache2/your-domain.com-error_log
    CustomLog /var/log/apache2/your-domain.com-access_log common

 </VirtualHost>

Remember to replace your-domain.com with the domain name of your server.

Save and exit the configuration file.

Then enable the "rewrite" module in Apache:

# a2enmod rewrite

To enable this site run the command:

# ln -s /etc/apache2/sites-available/elgg.conf /etc/apache2/sites-enabled/elgg.conf

To implement the changes, restart Apache webserver:

# systemctl restart apache2

Step 7: Install free Let’s Encrypt SSL certificate

First we need to install the Certbot client which is used to create Let’s Encrypt certificates:

# apt install certbot python3-certbot-apache

To get the SSL certificate using the Certbot, type the command given below:

# certbot --apache -d your-domain.com -d www.your-domain.com

If the SSL certificate is successfully obtained, certbot displays a message to show the configuration was successful:

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/your-domain.com.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/your-domain.com/privkey.pem
   Your cert will expire on 2023-09-02. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot
   again. To non-interactively renew *all* of your certificates, run
   "certbot renew"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

Now, you have successfully installed SSL on your website.

Step 8: Access Elgg Web Interface

Open your web browser and type the URL https://your-domain.com. You should see the following page:

Elgg Welcome Page

Click on the Next button.

Requirements check

The installer will then check the requirements. Once all checks are passed, click on the Next button.

Database installation

After that, you will have to write the credentials from the database, data directory, and site URL and then click on the Next button:

Configure site

Then, you have to set up your site name and email and then click on the Next button:

Create admin account

Provide your admin username, password, email and click on the Next button. Once the installation has been completed, you should see the following page:

Elgg finished installation

Click on the Go to site button you should see your administration panel:

Elgg Dashboard

Comments and Conclusion

Congratulations! You have successfully installed Elgg. Thanks for using this tutorial for installing Elgg on your Debian 12 OS.

For additional help or useful information, we recommend you to check  the official Elgg documentation.

Leave a Reply

Your email address will not be published. Required fields are marked *