Cannot create directory alias (with php pages)

Nikolaos Milas nmilas at
Wed Aug 13 20:42:58 UTC 2014


I have a hard time trying to make a "directory alias" (in Apache 
terminology - sorry, I still have a lot to learn on nginx)...

I have, configured to run piwik analytics (it is a php 
site), and it works fine.

I runs under nginx v1.6.1, php-fpm v5.3.3 on an updated CentOS 6.5 64bit 

Now, I want to create an /xhprof location, which includes php code and 
lives in another disk path (in: /usr/share/xhprof/xhprof_html). I can't 
make this work...

I have tried multiple possible solutions, googled around, but it just 
won't work.

Follows the attempted config. In this, calling or returns "404 Not Found".

The error log shows: "rewrite or internal redirection cycle while 
internally redirecting to "/xhprof".

server {

     listen [::]:80;

     access_log  /var/webs/wwwpiwik/log/access_log main;
     error_log /var/webs/wwwpiwik/log/error_log warn;
     root   /var/webs/wwwpiwik/www/;

     index  index.php index.html index.htm index.cgi default.html 
default.htm default.php;

     location / {
        try_files $uri $uri/ /index.php?$args;
        allow ::1;
        deny all;

     location /xhprof {

        alias /usr/share/xhprof/xhprof_html;

        try_files $uri $uri/ /xhprof$is_args$args;

        allow ::1;
        deny all;

     location ~ \.php$ {

        allow ::1;

        fastcgi_cache off;

        try_files $uri =404;
        include /etc/nginx/fastcgi_params;
        fastcgi_param PATH_INFO $fastcgi_script_name;

         fastcgi_intercept_errors on;

         fastcgi_buffer_size 384k;
         fastcgi_buffers 256 16k;
         fastcgi_busy_buffers_size 384k;
         fastcgi_temp_file_write_size 384k;
         fastcgi_read_timeout 240;

         fastcgi_pass unix:/tmp/php-fpm.sock;

         fastcgi_index index.php;
         include /etc/nginx/fastcgi_params;
         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;



I appreciate your help in correcting the /xhprof definition, in order to 
make it work...

I also

Thanks in advance,

More information about the nginx mailing list