Step-by-step installation of GLPI 10 on Debian 12

This tutorial will install GLPI 10 on a Debian 12 machine, setting up Apache2, PHP 8.2 (PHP-FPM), and MariaDB Server.

GLPI is a free IT asset management software that allows you to have a free ticketing solution for IT support, to manage the inventory of equipment, particularly computers, and telephones, to manage your contracts, licenses, consumables, server racks, etc…. Created in 2003, GLPI is a popular solution thousands of companies use.

Although its publisher, Teclib, offers a paid version hosted in SaaS mode, GLPI is always free, and you can host it on your server, whether for your internal needs or your customers, particularly for managing support tickets.

II. GLPI prerequisites

Before we talk about installation, let’s talk about the prerequisites. GLPI needs a web server, PHP, and a database to work. Under Linux, this corresponds to a LAMP base. It supports several web servers: Apache2, Nginx, Lighttpd, and IIS.

For the rest, here’s what you need to know:

  • PHP version
    • Minimum: PHP 7.4 (no longer supported!)
    • Maximum: PHP 8.2
  • Database
    • MySQL 5.1 minimum
    • MariaDB 10.2 minimum

There will also be several PHP extensions to install for GLPI to work.

The latest version of GLPI at the time of writing, namely GLPI 10.0.10, adds support for PHP 8.3 (future stable version) and MySQL 8.1, in addition to correcting many critical vulnerabilities.

For this demonstration, we will use a machine running Debian 12 and install Apache2, PHP 8.3, and MariaDB on it.

If you need further clarification, you can consult the official documentation:

III. Prepare the server to install GLPI

Let’s start with the installation by updating the packages on the Debian 12 machine. Also, remember to assign it an IP address and perform system configuration.

sudo apt-get update && sudo apt-get upgrade

A. Install the LAMP base

The first big step is to install the LAMP base package: Linux Apache2 MariaDB PHP. Under Debian 12, which is the latest stable version of Debian, PHP 8.2 is distributed by default in the official repositories.

Let’s start by installing these three packages:

sudo apt-get install apache2 php mariadb-server

Then, we will install all the extensions necessary for GLPI to work properly.

sudo apt-get install php-xml php-common php-json php-mysql php-mbstring php-curl php-gd php-intl php-zip php-bz2 php-imap php-apcu

These commands will allow you to retrieve the versions of these extensions for PHP 8.2.

If you plan to associate GLPI with an LDAP directory such as Active Directory, you must install the LDAP PHP extension. Otherwise, it is unnecessary, and you can do it later.

sudo apt-get install php-ldap

We just installed Apache2, MariaDB, PHP, and many extensions.

See also  How to install macOS on VirtualBox in minutes with "macos-guest-virtualbox.sh"

B. Prepare a database for GLPI

We will prepare MariaDB so that it can host the GLPI database. The first action is to execute the command below to perform the bare minimum in securing MariaDB.

sudo mysql_secure_installation

You will be prompted to change the root password and delete anonymous users, disable remote root access, etc… Everything is well explained. Here is an example on my server to guide you:

Securing MariaDB for GLPI

Next, we will create a dedicated database for GLPI, which will be accessible by a dedicated user. Using the MariaDB root account is out of the question: one database = one user.

Connect to your MariaDB instance:

sudo mysql -u root -p

Enter the MariaDB root password you set in the previous step.

Then, we will run the SQL queries below to create the database “db23_glpi” as well as the user “glpi_adm” with the password “StrongPassword” (which you change, of course). This user will have all rights to this database (and only this one).

CREATE DATABASE db23_glpi;
GRANT ALL PRIVILEGES ON db23_glpi.* TO glpi_adm@localhost IDENTIFIED BY "MotDePasseRobuste";
FLUSH PRIVILEGES;
EXIT

Which give :

Create GLPI database

There you go; the database is ready.

C. Download GLPI and prepare for its installation

The next step is to download the “.tgz” archive containing the GLPI installation sources. From the GLPI GitHub, get the link to the latest version. Here, GLPI version 10.0.10 is installed.

The archive will be downloaded to the “/tmp” directory:

cd /tmp
wget https://github.com/glpi-project/glpi/releases/download/10.0.10/glpi-10.0.10.tgz

Then, we will run the command below to unpack the .tgz archive into the “/var/www/” directory, giving the path ” /var/www/glpi ” for GLPI.

sudo tar -xzvf glpi-10.0.10.tgz -C /var/www/

We will define the user ” www-data,” corresponding to Apache2, as the owner of the GLPI files.

sudo chown www-data /var/www/glpi/ -R

Next, we will have to create several folders and take data out of the web root (/var/www/glpi) to store it in the new folders we will create. This will allow a secure installation of GLPI, which follows the publisher’s recommendations.

  • The /etc/glpi directory

Create the “/etc/glpi” directory to receive the GLPI configuration files. We give permissions to www-data on this directory because it needs to be able to access it.

sudo mkdir /etc/glpi
sudo chown www-data /etc/glpi/

Then, we will move the GLPI “config” directory to this new folder:

sudo mv /var/www/glpi/config /etc/glpi
  • The /var/lib/glpi directory

Let’s repeat the same operation with the creation of the “/var/lib/glpi” directory:

sudo mkdir /var/lib/glpi
sudo chown www-data /var/lib/glpi/

Which we also move the “ files ” folder, which contains the majority of GLPI files: CSS, plugins, etc.

sudo mv /var/www/glpi/files /var/lib/glpi
  • The /var/log/glpi directory

Let’s finish by creating the ” /var/log/glpi ” directory intended to store the GLPI logs. Still on the same principle:

sudo mkdir /var/log/glpi
sudo chown www-data /var/log/glpi

We don’t have to move anything into this directory.

  • Create configuration files
See also  Firefox on Android now supports more than 450 extensions

We need to configure GLPI to know where to fetch the data. In other words, we will declare the new, freshly created directories.

We will create this first file:

sudo nano /var/www/glpi/inc/downstream.php

To add the content below, which indicates the path to the configuration directory :

<?php
define('GLPI_CONFIG_DIR', '/etc/glpi/');
if (file_exists(GLPI_CONFIG_DIR . '/local_define.php')) {
    require_once GLPI_CONFIG_DIR . '/local_define.php';
}

Next, we will create this second file:

sudo nano /etc/glpi/local_define.php

To add the content below, declare two variables allowing you to specify the paths to the “files” and “log” directories we prepared previously.

<?php
define('GLPI_VAR_DIR', '/var/lib/glpi/files');
define('GLPI_LOG_DIR', '/var/log/glpi');

There you go; this step is complete.

D. Prepare Apache2 configuration

Let’s move on to configuring the Apache2 web server. We will create a new configuration file that will allow us to configure the VirtualHost dedicated to GLPI. In my case, the file is called “support.it-connect.tech.conf” about the domain name chosen to access GLPI: support.easy-tutorials.com. The idea is to have a domain name (even internal) to access GLPI to be able to position an SSL certificate subsequently.

sudo nano /etc/apache2/sites-available/support.it-connect.tech.conf

Which gives the following configuration (according to the official documentation model):

<VirtualHost *:80>
    ServerName support.easy-tutorials.com

    DocumentRoot /var/www/glpi/public

    # If you want to place GLPI in a subfolder of your site (e.g. your virtual host is serving multiple applications),
    # you can use an Alias directive. If you do this, the DocumentRoot directive MUST NOT target the GLPI directory itself.
    # Alias "/glpi" "/var/www/glpi/public"

    <Directory /var/www/glpi/public>
        Require all granted

        RewriteEngine On

        # Redirect all requests to GLPI router, unless file exists.
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^(.*)$ index.php [QSA,L]
    </Directory>
</VirtualHost>
Apache2 GLPI configuration

When the configuration is ready, save the file.

Then, we will activate this new site in Apache2 :

sudo a2ensite support.it-connect.tech.conf

We also take this opportunity to deactivate the default site because it is useless:

sudo a2dissite 000-default.conf

We will also activate the “rewrite” module (for the rewrite rules) because we used it in the VirtualHost configuration file ( RewriteCond / RewriteRule ).

sudo a2enmod rewrite

All that remains is to restart the Apache2 service :

sudo systemctl restart apache2

E. Using PHP8.2-FPM with Apache2

There are two possibilities to use PHP as a scripting engine with Apache2: the PHP module for Apache2 (libapache2-mod-php8.2) or PHP-FPM.

It is recommended to use PHP-FPM because it is more efficient and presents itself as an independent service. Each Apache2 process runs its own PHP scripting engine in the other mode.

If you want to use PHP-FPM, follow the steps below. Otherwise, move on, but make sure to configure the “session.cookie_httponly” option mentioned below.

We will start by installing PHP8.2-FPM with the following command:

sudo apt-get install php8.2-fpm

Then, we will activate two modules in Apache and configure PHP-FPM before reloading Apache2:

sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php8.2-fpm
sudo systemctl reload apache2

To configure PHP-FPM for Apache2, we are not going to edit the ” /etc/php/8.2/apache2/php.ini ” file but rather this file:

sudo nano /etc/php/8.2/fpm/php.ini

In this file, look for the option ” session.cookie_httponly ” and set the value “on” to enable it to protect GLPI’s cookies.

; Whether or not to add the httpOnly flag to the cookie, which makes it
; inaccessible to browser scripting languages such as JavaScript.
; https://php.net/session.cookie-httponly
session.cookie_httponly = on

Save the file when done. Subsequently, you may be required to make other modifications, in particular, to increase the size of uploads to GLPI, etc.

See also  Best Origami Android Apps with APK Files

To apply the changes, we need to restart PHP-FPM:

sudo systemctl restart php8.2-fpm.service

Finally, we need to modify our VirtualHost to specify to Apache2 that PHP-FPM should be used for PHP files:

<FilesMatch \.php$>
    SetHandler "proxy:unix:/run/php/php8.2-fpm.sock|fcgi://localhost/"
</FilesMatch>

Here is an example :

Apache2 and PHP-FPM - Example

When done, restart Apache2:

sudo systemctl restart apache2

There you go, everything is ready! All that remains is to install GLPI!

IV. Installing GLPI

To install GLPI, we must use a web browser to access the GLPI address. This is the address declared in the Apache2 configuration file ( ServerName ).

If you followed all the steps correctly, you should land on this page. We’ll start by choosing the language.

Installation of GLPI - Step 1

Since this is a new installation, we click ” Install “.

Installation of GLPI - Step 2

Important step: GLPI checks our server configuration to determine if all prerequisites are met. Everything is good, so we can continue.

Installation of GLPI - Step 3

In the next step, we must fill in the information to connect to the database. We indicate ” localhost ” as an SQL server since MariaDB is installed locally on the same server as GLPI. Then, we indicate our user “glpi_adm” and the associated password.

Installation of GLPI - Step 4

After clicking “ Continue ”, we must choose the previously created “ db23_glpi ” database.

Installation of GLPI - Step 5

Continue…

Installation of GLPI - Step 6

Follow the last steps, which have no real impact. The hardest thing is done!

Installation of GLPI - Step 7

Congratulations, you have just installed GLPI! As the last step specifies, the default administrator account is “ glpi/glpi ”!

Installation of GLPI - Step 8

We will therefore log in with the account “glpi” and the password “glpi”.

Note

Default user accounts are:

  • glpi/glpi admin account,
  • tech/tech technical account,
  • normal/normal “normal” account,
  • post-only/postonly post-only account.

Warning

You’ll have to delete or edit those accounts for obvious security concerns.

Before removing the glpi account, please make sure you have created another user with super-admin profile.

Installation of GLPI - Step 9

Welcome to your new GLPI server!

GLPI 10 installation completed

Even though the installation is complete, we still have a few actions to complete to finalize it:

  • Change the password for all default accounts (click the links in the orange box)
  • Delete the “install.php” file since it is no longer necessary and represents a risk (restart the installation)
sudo rm /var/www/glpi/install/install.php

There it’s done. From now on, your GLPI is ready to be used and configured (creation of users, categories, tickets, etc.).

V. Conclusion

By following this step-by-step tutorial, you should be able to install GLPI on a Debian 12 server! With few details, this procedure can be applied to other systems and versions. Feel free to post a comment or connect to our Discord server if you have a question.

Do you want more tutorials on GLPI? I can consider tutorials to switch it to HTTPS with a certificate, but also on deploying the GLPI agent, etc.

5/5 - (3 votes)

Mohamed SAKHRI

I am Mohamed SAKHRI, the creator and editor-in-chief of Tech To Geek, where I've demonstrated my passion for technology through extensive blogging. My expertise spans various operating systems, including Windows, Linux, macOS, and Android, with a focus on providing practical and valuable guides. Additionally, I delve into WordPress-related subjects. You can find more about me on my Linkedin!, Twitter!, Reddit

Leave a Comment