How to install GLPI on linux server with NGINX
Tags: programming, devops, nginx, glpi
Published: 2023-12-17 04:55:53

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 

``` bash
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
```

- For CentOS/RHEL

``` bash
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
```


## 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:

``` bash
mysql -u root -p
```

``` bash
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;
```

## 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:

``` bash
sudo unzip glpi-<version>.zip -d /var/www/html/
```

## 4. Set Permissions

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

``` bash
sudo chown -R www-data:www-data /var/www/html/glpi/
```

## 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:

``` bash
sudo nano /etc/nginx/sites-available/glpi
```

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

``` nginx
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;
    }
}
```


## 6. Enable the Nginx Server Block

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

``` bash 
sudo ln -s /etc/nginx/sites-available/glpi /etc/nginx/sites-enabled/
```

## 7. Test Nginx Configuration

Check if your Nginx configuration is correct:

``` bash
sudo nginx -t
```

## 8. Start Nginx

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

``` bash
sudo systemctl restart nginx
```

## 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.