Cannot create directory alias (with php pages)

Francis Daly francis at
Thu Aug 14 12:26:03 UTC 2014

On Thu, Aug 14, 2014 at 02:06:38PM +0300, Nikolaos Milas wrote:
> On 13/8/2014 11:42 μμ, Nikolaos Milas wrote:

Hi there,

> I have modified configuration as follows; the /xprof location works
> (i.e. I can access non php files), but all php files cannot be
> accessed (message: 404 Not Found). Nothing is recorded in the error
> log.
> Why can't I access the php files in /usr/share/xhprof/xhprof_htmlas
> /xhprof/filename.php ?

The request is /xhprof/filename.php; that should be handled in this

>     location ~ /xhprof(.+\.php)$ {
>        alias /usr/share/xhprof/xhprof_html$1;
>        try_files $uri =404;

The combination of a regex location, alias, and try_files, probably does
not do what you want.

I suspect that the 404-with-no-error-log comes from this try_files line.

You could (temporarily) either remove the line, or replace it with

  try_files "" =404;

in order to get through to the next stage of the configuration.

>        include /etc/nginx/fastcgi_params;
>        fastcgi_param PATH_INFO $fastcgi_script_name;
>         fastcgi_pass unix:/tmp/php-fpm.sock;
>         include /etc/nginx/fastcgi_params;
>         fastcgi_param SCRIPT_FILENAME $document_root$1;

alias with variables (and possibly try_files, I don't recall) probably
leave some of these variables in a state you don't expect.

Your fastcgi server, when it receives repeated fastcgi params, will
probably only honour the first or the last one received. If you care,
test so that you know, or don't send repeat params (by editing the
fastcgi_params files, and only including it once).

So: what file-on-the-filesystem do you want your fastcgi server to

What variable or variables in nginx make up exactly that name?

Put that in as SCRIPT_FILENAME.

(It may be that $document_root is all you need here.)

You can see what nginx sends by looking in the debug log; or by watching
the traffic going from nginx to the fastcgi server. Or maybe your fastcgi
server has its own logging.

Francis Daly        francis at

More information about the nginx mailing list