Menu

9/2/24

Tạo virtual host cho GLPI

 How to create a VirtualHost dedicated to GLPI?

  • Create a file on /etc/apache2/sites-available/glpi.conf
root@local# vi /etc/apache2/sites-available/glpi.conf
  • In this file, you will add the following content:
    # Start of the VirtualHost configuration for port 80
    
    <VirtualHost *:80>
        ServerName yourglpi.yourdomain.com
        # Specify the server's hostname
        DocumentRoot /var/www/html/glpi/public
        # The directory where the website's files are located
        # Start of a Directory directive for the website's directory
        <Directory /var/www/html/glpi/public>
            Require all granted
            # Allow all access to this directory
            RewriteEngine On
            # Enable the Apache rewrite engine
            # Ensure authorization headers are passed to PHP.
            # Some Apache configurations may filter them and break usage of API, CalDAV, ...
            RewriteCond %{HTTP:Authorization} ^(.+)$
            RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
            # Redirect all requests to GLPI router, unless the file exists.
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^(.*)$ index.php [QSA,L]
        </Directory>
        # End of the Directory directive for /var/www/glpi/public
    </VirtualHost>
    
    # End of the VirtualHost configuration for port 80
  • ServerName if you have a public URL, you can type it here
  • DocumentRoot if you will store GLPI in a different page, change it too.

After the Virtual Host file is created you should disable the default apache site configuration, enable the rewrite module and reload the new vhost file.

a2dissite 000-default.conf # Disable default apache site
a2enmod rewrite # enable the rewrite module
a2ensite glpi.conf # enable the new apache virtual host settings for your glpi instance
systemctl restart apache2

No comments:

Post a Comment