How do I install ViMP under NGINX?

Editions: Light, Ultimate, Corporate
Versions: 4.3.0+

Starting with version 4.3.0 you can also run ViMP under NGINX. Just install NGINX with PHP-FPM on your server. In the following we assume that NGINX is already running and PHP files can be delivered.

Then create a new NGINX server configuration under /etc/nginx/sites-enabled (e.g. vimp.conf) or alternatively edit your existing default configuration. The NGINX server configuration for ViMP must look like this:

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/framework/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/vimp/logs/nginx_access.log;
error_log /var/www/vimp/logs/nginx_error.log warn;
  index index.php frontend.php backend.php frontend_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;
}
  # Hack for dynamic JS files which are processed by PHP
location ~ ^/(.+)\.js\.php(/|$) {
error_page 418 = @appfrontend;
error_page 419 = @appbackend;
    if ( $query_string ~ "app=frontend" ) { return 418; }
if ( $query_string ~ "app=backend" ) { return 419; }
}
  # Hack for dynamic JS files which are processed by PHP
location @appfrontend {
index index.php;
    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;
}
  # Hack for dynamic JS files which are processed by PHP
location @appbackend {
index backend.php;
    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(/|$) {
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;
}
}

 

Last update on 2020/10/29 by Admin.

Go back