There was a problem loading the comments.

How do I install VIMP under NGINX?

Support Portal  »  Knowledgebase (FAQ)  »  Viewing Article

  Print
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 configuration for VIMP must look like this (replace the root directory and the server name and log directories according to your server configuration):

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;
  add_header Access-Control-Allow-Origin * always;
  
  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; }
return 418 } # 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_buffers 32 256k; fastcgi_buffer_size 512k; fastcgi_busy_buffers_size 512k; fastcgi_param HTTPS off; try_files $uri $uri/ /index.php$is_args$query_string; } # Directive for dynamic JS files which are processed by PHP (no longer needed for VIMP 5.1 and higher) 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_buffers 32 256k; fastcgi_buffer_size 512k; fastcgi_busy_buffers_size 512k; fastcgi_param HTTPS off; try_files $uri $uri/ /webtv.php$is_args$query_string; } # 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_buffers 32 256k; fastcgi_buffer_size 512k; fastcgi_busy_buffers_size 512k; fastcgi_param HTTPS off; try_files $uri $uri/ /backend.php$is_args$query_string; } # All front controllers for vimp location ~ ^/(index|frontend_dev|frontend_cache|backend|backend_dev|backend_cache|getMedia|health|webtv|webtv_dev|webtv_cache|restoreProgress|updateProgress|js/jsdeliverer)\.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_buffers 32 256k; fastcgi_buffer_size 512k; fastcgi_busy_buffers_size 512k; fastcgi_param HTTPS off; } location @jsdeliverer { index js/jsdeliverer.php; try_files _ /js/jsdeliverer.php$is_args$query_string; } location /js { rewrite ^/js/$ /js/*.js; if (!-e $request_filename) { error_page 420 = @jsdeliverer; return 420; } } # 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; } }


Note: Be sure to set fastcgi_param HTTPS to "on" when you're running your website under https!


Share via

Related Articles

© VIMP GmbH