About Features Downloads Getting Started Documentation Events Support GitHub

Love VuFind®? Consider becoming a financial supporter. Your support helps build a better VuFind®!

Site Tools


Warning: This page has not been updated in over over a year and may be outdated or deprecated.
installation:nginx

Using Nginx with VuFind®

You can serve VuFind® using Nginx as an alternative to Apache. There is not currently an officially distributed Nginx configuration, but the examples below may help you get things working.

Example 1

This example configuration was shared by Sascha-Oliver Prolic.

server {

    listen 80;
    root /path/to/vufind2/public;
    index index.html index.htm index.php;

    server_name your-server-name;

    location / {
        try_files $uri $uri/ /index.php$is_args$args;
      }

    location ~ ^/themes/([0-9a-zA-Z-_]*)/css/(.*)$ {
      default_type text/css;
      alias /path/to/vufind2/themes/$1/css/$2;
    }

    location ~ ^/themes/([0-9a-zA-Z-_]*)/images/(.*)$ {
      alias /path/to/vufind2/themes/$1/images/$2;
    }

    location ~ ^/themes/([0-9a-zA-Z-_]*)/js/(.*)$ {
      alias /path/to/vufind2/themes/$1/js/$2;
    }

    location ~ \.php$ {
                fastcgi_param VUFIND_ENV development;
                fastcgi_param APPLICATION_ENV development;
                fastcgi_param VUFIND_HOME /path/to/vufind2;
                fastcgi_param VUFIND_LOCAL_DIR /path/to/vufind2/local;
                fastcgi_param VUFIND_LOCAL_MODULES your-module-name;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                include fastcgi_params;
    }
}

Example 2

This example configuration was shared by Horacio Degiorgi.

If you want to serve VuFind® in a different location (in this case, “/explorador”) you can use alias and rewrite instead of try_files.

 location ~ /explorador/themes/([0-9a-zA-Z-_]*)/css/(.*)$ {
      default_type text/css;
      alias /usr/local/vufind/themes/$1/css/$2;
    }

    location ~ /explorador/themes/([0-9a-zA-Z-_]*)/images/(.*)$ {
      alias /usr/local/vufind/themes/$1/images/$2;
    }

    location ~ /explorador/themes/([0-9a-zA-Z-_]*)/js/(.*)$ {
      alias /usr/local/vufind/themes/$1/js/$2;
    }

location /explorador/ {
    alias /usr/local/vufind/public/;
    index index.php;
    ## Check for file existing and if there, stop ##
    if (-f $request_filename) {
        break;
    }

    ## Check for file existing and if there, stop ##
    if (-d $request_filename) {
        break;
    }

    ## If we get here then there is no file or directory matching request_filename ##
    rewrite (.*) /explorador/index.php?$query_string;

    location ~ \.php$ {
                fastcgi_intercept_errors on;
                fastcgi_param SCRIPT_FILENAME $request_filename;
#               fastcgi_param VUFIND_ENV development;
#               fastcgi_param APPLICATION_ENV development;
                fastcgi_param VUFIND_HOME /usr/local/vufind;
                fastcgi_param VUFIND_LOCAL_DIR /usr/local/vufind/local;
#               fastcgi_param VUFIND_LOCAL_MODULES your-module-name;
#               fastcgi_pass unix:/run/php/php7.0-fpm.sock;
                fastcgi_pass 127.0.0.1:9090;
                fastcgi_index index.php;
                include fastcgi_params;
    }
}
installation/nginx.txt · Last modified: 2023/11/28 20:37 by demiankatz