DiouxX / docker-glpi

Project to deploy GLPI with docker
219 stars 185 forks source link

Issue GLPI 10.0.6 after update the image #89

Closed krystianroza closed 10 months ago

krystianroza commented 1 year ago

The newest glpi-start.sh has probably an error at line 38 echo -e "<VirtualHost :80>\n\tDocumentRoot /var/www/html/glpi/public\n\n\t<Directory /var/www/html/glpi/public>\n\t\tRequire all granted\n\t\tRewriteEngine On\n\t\tRewriteCond %{REQUEST_FILENAME} !-f\n\t\n\t\tRewriteRule ^(.)$ index.php [QSA,L]\n\t\n\n\tErrorLog /var/log/apache2/error-glpi.log\n\tLogLevel warn\n\tCustomLog /var/log/apache2/access-glpi.log combined\n" > /etc/apache2/sites-available/000-default.conf

in this line the path is glpi without subfolder public for GLPI 10.0.6 I have checked glpi-10.0.6 \glpi\public\ (no index.php) Maybe You should check directory glpi\version\

I have started using Your scripts from 10.0.6 and after upgrade i was having an error. Right now I manually corrected the apache2 site conf and reload it, but if container will restart the issue will come back :(

DiouxX commented 1 year ago

Yes, you are right !

I need to check if the currently installed version is < 10.0.7. If so, the apache configuration should be as follows :

<VirtualHost *:80>
    DocumentRoot /var/www/html/glpi

        <Directory /var/www/html/glpi>
                     AllowOverride All
                     Order Allow,Deny
                     Allow from all
         </Directory>

          ErrorLog /var/log/apache2/error-glpi.log
          LogLevel warn
          CustomLog /var/log/apache2/access-glpi.log combined
</VirtualHost>

If the GLPI aversion >= 10.0.7 then the apache configuration must be similar the one indicated in the following documentation

<VirtualHost *:80>
    ServerName glpi.localhost

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

I implement this fix in the day.

DiouxX commented 1 year ago

I created this PR https://github.com/DiouxX/docker-glpi/pull/91 and merged to master branch

I added the following code section to glpi.start.sh file

#Adapt the Apache server according to the version of GLPI installed
## Extract local version installed
LOCAL_GLPI_VERSION=$(ls ${FOLDER_WEB}/${FOLDER_GLPI}/version)
## Extract major version number
LOCAL_GLPI_MAJOR_VERSION=$(echo $LOCAL_GLPI_VERSION | cut -d. -f1)
## Remove dots from version string
LOCAL_GLPI_VERSION_NUM=${LOCAL_GLPI_VERSION//./}

## Target value is GLPI 1.0.7
TARGET_GLPI_VERSION="10.0.7"
TARGET_GLPI_VERSION_NUM=${TARGET_GLPI_VERSION//./}
TARGET_GLPI_MAJOR_VERSION=$(echo $TARGET_GLPI_VERSION | cut -d. -f1)

# Compare the numeric value of the version number to the target number
if [[ $LOCAL_GLPI_VERSION_NUM -lt $TARGET_GLPI_VERSION_NUM || $LOCAL_GLPI_MAJOR_VERSION -lt $TARGET_GLPI_MAJOR_VERSION ]]; then
  echo -e "<VirtualHost *:80>\n\tDocumentRoot /var/www/html/glpi\n\n\t<Directory /var/www/html/glpi>\n\t\tAllowOverride All\n\t\tOrder Allow,Deny\n\t\tAllow from all\n\t</Directory>\n\n\tErrorLog /var/log/apache2/error-glpi.log\n\tLogLevel warn\n\tCustomLog /var/log/apache2/access-glpi.log combined\n</VirtualHost>" > /etc/apache2/sites-available/000-default.conf
else
  set +H
  echo -e "<VirtualHost *:80>\n\tDocumentRoot /var/www/html/glpi/public\n\n\t<Directory /var/www/html/glpi/public>\n\t\tRequire all granted\n\t\tRewriteEngine On\n\t\tRewriteCond %{REQUEST_FILENAME} !-f\n\t\n\t\tRewriteRule ^(.*)$ index.php [QSA,L]\n\t</Directory>\n\n\tErrorLog /var/log/apache2/error-glpi.log\n\tLogLevel warn\n\tCustomLog /var/log/apache2/access-glpi.log combined\n</VirtualHost>" > /etc/apache2/sites-available/000-default.conf
fi

It checks the version of GLPI installed, whether it is recent or existing If it's < 10.0.7, it's the "old" vhost apache version is configured Otherwise, it's the "new" vhost apache version configured

Before merging, I tried on existing GLPI installations. According to my tests, this issue should be solved

Can you confirm from your side ?

krystianroza commented 1 year ago

I will confirm tomorrow when my container will upgrades :) At 4 AM I have autoupgrade with backups before :)