Skip to content

Commit 194877e

Browse files
authored
Merge pull request #521 from mapbender/work/nginx-docs
Added nginx configuration to installation guide
2 parents d58bd37 + ad18109 commit 194877e

File tree

4 files changed

+97
-7
lines changed

4 files changed

+97
-7
lines changed

de/installation/installation_ubuntu.rst

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ Voraussetzungen
1616
* Apache Installation mit folgenden aktivierten Modulen:
1717
* mod_rewrite
1818
* libapache2-mod-php
19+
* alternativ: nginx-Installation mit folgenden aktivierten Modulen:
20+
* php-fpm
1921
* PostgreSQL Installation
2022
* Es wird empfohlen, eine PostgreSQL Datenbank für Mapbender zu verwenden.
2123
* Es wird empfohlen, einen eigenen Datenbankbenutzer für den Zugriff auf die Mapbender Datenbank anzulegen.
2224

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

2626
Vorbereitung
2727
------------
@@ -71,6 +71,50 @@ Aktivieren der Seite und Apache neu starten:
7171
7272
a2ensite mapbender.conf
7373
service apache2 reload
74+
75+
Konfiguration nginx
76+
-------------------
77+
78+
Alternativ zu Apache kann auch nginx verwendet werden.
79+
Dafür muss eine eigene Konfiguration in ``/etc/nginx/sites-available`` angelegt werden:
80+
81+
.. code-block:: nginx
82+
83+
server {
84+
listen 80;
85+
listen [::]:80;
86+
server_name mapbender.localhost # bitte anpassen
87+
88+
# SSL-Konfiguration wird hier empfohlen sofern der Mapbender nicht lokal ausgeführt wird
89+
90+
root /var/www/mapbender/application/public;
91+
92+
index index.php;
93+
94+
location / {
95+
# Versuche zunächst als Datei auszuliefern, dann als Verzeichnis,
96+
# alles andere wird an die index.php weitergeleitet
97+
try_files $uri $uri/ /index.php$is_args$args;
98+
}
99+
100+
# PHP-Skripte an den FastCGI server weitergeben
101+
location ~ \.php$ {
102+
include snippets/fastcgi-php.conf;
103+
fastcgi_pass unix:/run/php/php8.3-fpm.sock; # bitte anpassen, wenn eine andere PHP-Version verwendet wird
104+
}
105+
106+
# Zugriff auf Apache-Konfiugurationsdateien verbieten
107+
location ~ /\.ht {
108+
deny all;
109+
}
110+
}
111+
112+
Aktivieren der Seite und nginx neu starten:
113+
114+
.. code-block:: bash
115+
116+
ln -s /etc/nginx/sites-available/mapbender /etc/nginx/sites-enabled/
117+
systemctl restart nginx
74118
75119
76120
Verzeichnisrechte

de/installation/installation_windows.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ Voraussetzungen
2222
* Es wird empfohlen, einen eigenen Datenbankbenutzer für den Zugriff auf die Mapbender Datenbank anzulegen.
2323

2424

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

2728

2829
Konfiguration PHP

en/installation/installation_ubuntu.rst

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ Requirements
1616
* Apache installation with the following modules activated:
1717
* mod_rewrite
1818
* libapache2-mod-php
19+
* alternatively: nginx installation with the following modules activated:
20+
* php-fpm
1921
* PostgreSQL Installation
2022
* It is recommended to use a PostgreSQL database for Mapbender.
2123
* It is recommended to create a database user to access the Mapbender database.
2224

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

2626
Preparation
2727
-----------
@@ -72,6 +72,51 @@ Activate the site and reload Apache:
7272
a2ensite mapbender.conf
7373
service apache2 reload
7474
75+
Configuration nginx
76+
-------------------
77+
78+
As an alternative to apache2, nginx can also be used as webserver.
79+
To use Mapbender in nginx, create a configuration file within ``/etc/nginx/sites-available``:
80+
81+
.. code-block:: nginx
82+
83+
server {
84+
listen 80;
85+
listen [::]:80;
86+
server_name mapbender.localhost # change this to your needs
87+
88+
# recommended to setup ssl here when not in a local environment
89+
90+
root /var/www/mapbender/application/public;
91+
92+
index index.php;
93+
94+
location / {
95+
# First attempt to serve request as file, then
96+
# as directory, then redirect to index.php
97+
try_files $uri $uri/ /index.php$is_args$args;
98+
}
99+
100+
# pass PHP scripts to FastCGI server
101+
location ~ \.php$ {
102+
include snippets/fastcgi-php.conf;
103+
fastcgi_pass unix:/run/php/php8.3-fpm.sock; # change this when using another PHP version
104+
}
105+
106+
# deny access to .htaccess files, if Apache's document root
107+
# concurs with nginx's one
108+
location ~ /\.ht {
109+
deny all;
110+
}
111+
}
112+
113+
Activate the new site and restart nginx:
114+
115+
.. code-block:: bash
116+
117+
ln -s /etc/nginx/sites-available/mapbender /etc/nginx/sites-enabled/
118+
systemctl restart nginx
119+
75120
76121
Directory rights
77122
----------------

en/installation/installation_windows.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ Requirements
2222
* It is recommended to create a database user to access the Mapbender database.
2323

2424

25-
Nginx can also be used as web server, but it will not be discussed in this manual.
26-
25+
As a web server, you can also use nginx, which is considered a beta version for Windows. If you still want to use it,
26+
you can use the same configuration file as in the Linux installation guide.
2727

2828
Configuration PHP
2929
-----------------

0 commit comments

Comments
 (0)