Wie installiere ich ViMP unter NGINX?

Editionen: Light, Ultimate, Corporate
Versionen: 4.3.0+

Ab Version 4.3.0 können Sie ViMP auch unter NGINX betreiben. Installatieren Sie dazu NGINX mit PHP-FPM auf Ihrem Server. Wir gehen im folgenden davon aus, dass NGINX bereits läuft und PHP-Dateien ausgeliefert werden können.

Erstellen Sie dann eine neue NGINX Serverkonfiguration unter /etc/nginx/sites-enabled (z.B. vimp.conf) bzw. bearbeiten Sie alternativ Ihre bestehende Default-Konfiguration.

Die NGINX-Konfiguration für ViMP muss folgendermaßen aussehen (ersetzen Sie dabei das Root-Verzeichnis sowie den Servernamen und die Log-Verzeichnisse entsprechend Ihrer Serverkonfiguration):

server {
  rewrite_log off;
 
  listen 80;
  listen [::]:80 ipv6only=on;

  # replace /var/www/vimp/ with your actual ViMP installation folder path in the following line
  root /var/www/vimp/web;

  # replace your_servername with your actual server name in the following line
  server_name your_servername;

  # replace /var/www/vimp/ with your actual ViMP installation folder path in the following lines
  access_log /var/www/logs/vimp_nginx_access.log;
  error_log /var/www/logs/vimp_nginx_error.log warn;

  index index.php frontend.php webtv.php backend.php frontend_dev.php webtv_dev.php backend_dev.php index.html;

  charset utf-8;
  server_tokens off;

  client_max_body_size 500M;

  # Disable access log for favicon.ico
  location = /favicon.ico {
    log_not_found off;
    access_log off;
  }

  # Disable access log for robots.txt
  location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
  }

  # Prevent access to files/folders which starts with a dot
  location ~ /\. {
    deny all;
    access_log off;
    log_not_found off;
  }

  # Directive for dynamic JS files which are processed by PHP
  location ~ ^/(.+)\.js\.php(/|$) {
    error_page 417 = @appwebtv;
    error_page 418 = @appfrontend;
    error_page 419 = @appbackend;
    if ( $query_string ~ "app=webtv" ) { return 417; }
    if ( $query_string ~ "app=frontend" ) { return 418; }
    if ( $query_string ~ "app=backend" ) { return 419; }
  }

  # Directive for dynamic JS files which are processed by PHP
  location @appfrontend {
    index index.php;
    #include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
    #fastcgi_pass 127.0.0.1:9000;
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param HTTPS off;
    try_files $uri $uri/ /index.php;
  }

  # Directive for dynamic JS files which are processed by PHP
  location @appwebtv {
    index webtv.php;
    #include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
    #fastcgi_pass 127.0.0.1:9000;
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param HTTPS on;
    try_files $uri $uri/ /webtv.php;
  }

  # Directive for dynamic JS files which are processed by PHP
  location @appbackend {
    index backend.php;
    #include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
    #fastcgi_pass 127.0.0.1:9000;
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param HTTPS off;
    try_files $uri $uri/ /backend.php;
  }

  # All front controllers for symfony
  location ~ ^/(index|frontend_dev|frontend_cache|backend|backend_dev|backend_cache|getMedia|health|webtv|webtv_dev|webtv_cache)\.php(/|$) {
    #include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
    #fastcgi_pass 127.0.0.1:9000;
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param HTTPS off;
  }

  # Try to serve file directly, fallback to rewrite to default frontend controller
  location / {
    index index.php;
    try_files $uri $uri/ @rewriteapp;
  }

  # Rewrite fallback to index.php
  location @rewriteapp {
    rewrite ^(.*)$ /index.php$1 last;
  }
}

Hinweis: Achten Sie darauf, fastcgi_param HTTPS auf "on" zu setzen, wenn Sie Ihre Website unter https betreiben!

 

Zuletzt aktualisiert am 22.02.2021 von Admin.

Zurück