0

I have a little problem. I have a wordpress installation in

/var/www/xyz/wordpress    

and now I want to have a piwik installation in the path

/var/www/xyz/piwik

My current nginx configuration looks like this:

server {

    ...

    root /var/www/xyz/wordpress;
    index index.html index.php;

    location / {
            try_files $uri $uri/ /index.php?q=$request_uri;
    }

    location /piwik/ {
            root /var/www/xyz/piwik;
    }

    location ~ ^(.+?\.php)(/.*)?$ {
            try_files $1 =404;
            fastcgi_pass unix:/var/run/php-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
    }
}

Unfortunately, it does not work. Any ideas / tips to configure nginx?

user3641396
  • 31
  • 1
  • 1
  • 1

1 Answers1

3

This is a common misunderstanding in nginx configuration.

Try this:

location /piwik/ {
    alias /var/www/xyz/piwik/;
}
Tero Kilkanen
  • 36,796
  • 3
  • 41
  • 63
  • Nop, this does not work. But now with `root` as directive, it works. – user3641396 Jan 25 '15 at 12:40
  • 2
    For anyone else who stumbles upon this answer, the problem with this answer is that when using the `alias` directive, you also need to have the trailing slash in the aliased location, if your location regex contains the trailing slash. – Irvin Lim Jan 08 '17 at 22:12