DEV Community

Cover image for How to install GLPI on linux server with NGINX
Nickson Elauriche Toho
Nickson Elauriche Toho

Posted on

How to install GLPI on linux server with NGINX

To install GLPI on a Linux server with Nginx, you can follow these steps. GLPI is a free and open-source IT asset management and helpdesk system.

1. Prepare your server

Ensure that your Linux server is up-to-date and has the necessary components installed. You’ll need a web server (Nginx), PHP, a database server (usually MySQL or MariaDB), and some additional PHP extensions. You can install these packages using your Linux distribution’s package manager (e.g., apt for Debian/Ubuntu or yum for CentOS/RHEL). For example:

  • For Debian/Ubuntu
sudo apt update
sudo apt install nginx mysql-server php-fpm php-mysql php-curl php-gd php-ldap php-xml php-mbstring php-zip
Enter fullscreen mode Exit fullscreen mode
  • For CentOS/RHEL
sudo yum update
sudo yum install nginx mariadb-server php-fpm php-mysql php-curl php-gd php-ldap php-xml php-mbstring php-zip
Enter fullscreen mode Exit fullscreen mode

2. Configure MySQL/MariaDB

Set up a MySQL/MariaDB database and user for GLPI. Replace <db_user>, <db_password>, and <db_name> with your desired values:

mysql -u root -p
Enter fullscreen mode Exit fullscreen mode
CREATE DATABASE <db_name>;
CREATE USER '<db_user>'@'localhost' IDENTIFIED BY '<db_password>';
GRANT ALL PRIVILEGES ON <db_name>.* TO '<db_user>'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Enter fullscreen mode Exit fullscreen mode

3. Download and Extract GLPI

You can download the latest GLPI version from the official website. Upload the downloaded ZIP file to your server and extract it to your web server’s document root directory. For example:

sudo unzip glpi-<version>.zip -d /var/www/html/
Enter fullscreen mode Exit fullscreen mode

4. Set Permissions

Adjust permissions on the GLPI directory to ensure the web server can read and write files as needed:

sudo chown -R www-data:www-data /var/www/html/glpi/
Enter fullscreen mode Exit fullscreen mode

5. Create Nginx Server Block

Create an Nginx server block (virtual host) configuration for GLPI. Replace <your_domain> with your domain name or server IP address:

sudo nano /etc/nginx/sites-available/glpi
Enter fullscreen mode Exit fullscreen mode

Add the following configuration, making sure to adjust the paths and server_name as needed:

server {
    listen 80;
    server_name <your_domain>;
    root /var/www/html/glpi;

    location / {
        index index.php;
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; # Adjust the PHP-FPM socket path
    }

    location ~ /\.ht {
        deny all;
    }
}
Enter fullscreen mode Exit fullscreen mode

6. Enable the Nginx Server Block

Create a symbolic link to your configuration file in the sites-enabled directory:

sudo ln -s /etc/nginx/sites-available/glpi /etc/nginx/sites-enabled/
Enter fullscreen mode Exit fullscreen mode

7. Test Nginx Configuration

Check if your Nginx configuration is correct:

sudo nginx -t
Enter fullscreen mode Exit fullscreen mode

8. Start Nginx

If the configuration test is successful, restart Nginx to apply the changes:

sudo systemctl restart nginx
Enter fullscreen mode Exit fullscreen mode

9. Finish the Installation

Open a web browser and access your GLPI installation using your server’s domain name or IP address. You should see the GLPI installation wizard. Follow the wizard to complete the installation, providing the database credentials and other required information.

10. Secure Your Installation (Optional)

After installation, it’s crucial to secure your GLPI instance. Ensure you change the default administrator password and follow GLPI’s security guidelines.

Your GLPI installation should now be accessible via your web browser and running behind Nginx. Remember to regularly back up your GLPI data and keep the system updated for security purposes.

Top comments (0)