Skip to content

Commit

Permalink
Merge pull request #521 from mapbender/work/nginx-docs
Browse files Browse the repository at this point in the history
Added nginx configuration to installation guide
  • Loading branch information
astroidex authored Jan 30, 2025
2 parents d58bd37 + ad18109 commit 194877e
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 7 deletions.
48 changes: 46 additions & 2 deletions de/installation/installation_ubuntu.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ Voraussetzungen
* Apache Installation mit folgenden aktivierten Modulen:
* mod_rewrite
* libapache2-mod-php
* alternativ: nginx-Installation mit folgenden aktivierten Modulen:
* php-fpm
* PostgreSQL Installation
* Es wird empfohlen, eine PostgreSQL Datenbank für Mapbender zu verwenden.
* Es wird empfohlen, einen eigenen Datenbankbenutzer für den Zugriff auf die Mapbender Datenbank anzulegen.

Als Webserver kann auch nginx verwendet werden. In dieser Anleitung wird darauf nicht weiter eingegangen.


Vorbereitung
------------
Expand Down Expand Up @@ -71,6 +71,50 @@ Aktivieren der Seite und Apache neu starten:
a2ensite mapbender.conf
service apache2 reload
Konfiguration nginx
-------------------

Alternativ zu Apache kann auch nginx verwendet werden.
Dafür muss eine eigene Konfiguration in ``/etc/nginx/sites-available`` angelegt werden:

.. code-block:: nginx
server {
listen 80;
listen [::]:80;
server_name mapbender.localhost # bitte anpassen
# SSL-Konfiguration wird hier empfohlen sofern der Mapbender nicht lokal ausgeführt wird
root /var/www/mapbender/application/public;
index index.php;
location / {
# Versuche zunächst als Datei auszuliefern, dann als Verzeichnis,
# alles andere wird an die index.php weitergeleitet
try_files $uri $uri/ /index.php$is_args$args;
}
# PHP-Skripte an den FastCGI server weitergeben
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.3-fpm.sock; # bitte anpassen, wenn eine andere PHP-Version verwendet wird
}
# Zugriff auf Apache-Konfiugurationsdateien verbieten
location ~ /\.ht {
deny all;
}
}
Aktivieren der Seite und nginx neu starten:

.. code-block:: bash
ln -s /etc/nginx/sites-available/mapbender /etc/nginx/sites-enabled/
systemctl restart nginx
Verzeichnisrechte
Expand Down
3 changes: 2 additions & 1 deletion de/installation/installation_windows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ Voraussetzungen
* Es wird empfohlen, einen eigenen Datenbankbenutzer für den Zugriff auf die Mapbender Datenbank anzulegen.


Als Webserver kann auch Nginx verwendet werden. In dieser Anleitung wird darauf nicht weiter eingegangen.
Als Webserver kann auch Nginx verwendet werden, der für Windows aber als Beta-Version betrachtet wird. Sollte es trotzdem
gewünscht sein, nginx auf Windows zu verwenden, kann die gleiche Konfiguration wie für die Linux-Installation verwendet werden.


Konfiguration PHP
Expand Down
49 changes: 47 additions & 2 deletions en/installation/installation_ubuntu.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ Requirements
* Apache installation with the following modules activated:
* mod_rewrite
* libapache2-mod-php
* alternatively: nginx installation with the following modules activated:
* php-fpm
* PostgreSQL Installation
* It is recommended to use a PostgreSQL database for Mapbender.
* It is recommended to create a database user to access the Mapbender database.

Nginx can also be used as web server (this will not be discussed in detail here).


Preparation
-----------
Expand Down Expand Up @@ -72,6 +72,51 @@ Activate the site and reload Apache:
a2ensite mapbender.conf
service apache2 reload
Configuration nginx
-------------------

As an alternative to apache2, nginx can also be used as webserver.
To use Mapbender in nginx, create a configuration file within ``/etc/nginx/sites-available``:

.. code-block:: nginx
server {
listen 80;
listen [::]:80;
server_name mapbender.localhost # change this to your needs
# recommended to setup ssl here when not in a local environment
root /var/www/mapbender/application/public;
index index.php;
location / {
# First attempt to serve request as file, then
# as directory, then redirect to index.php
try_files $uri $uri/ /index.php$is_args$args;
}
# pass PHP scripts to FastCGI server
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.3-fpm.sock; # change this when using another PHP version
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
location ~ /\.ht {
deny all;
}
}
Activate the new site and restart nginx:

.. code-block:: bash
ln -s /etc/nginx/sites-available/mapbender /etc/nginx/sites-enabled/
systemctl restart nginx
Directory rights
----------------
Expand Down
4 changes: 2 additions & 2 deletions en/installation/installation_windows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ Requirements
* It is recommended to create a database user to access the Mapbender database.


Nginx can also be used as web server, but it will not be discussed in this manual.

As a web server, you can also use nginx, which is considered a beta version for Windows. If you still want to use it,
you can use the same configuration file as in the Linux installation guide.

Configuration PHP
-----------------
Expand Down

0 comments on commit 194877e

Please sign in to comment.