php not working from aliased subdir

Nikolaos Milas nmilas at
Tue Jan 19 09:21:46 UTC 2016


I have been adding (to my nginx config) directories outside of the 
default "root" tree like:

     location ~ /newlocation(.*) {
         alias /var/websites/externaldir$1;

This works OK.

however, I find that the above config does not process php files. I 
tried adding (before the above):

     location ~ /newlocation/(.*)\.php$ {

         alias /var/websites/externaldir$1.php;

         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 128k;
         fastcgi_buffers 256 16k;
         fastcgi_busy_buffers_size 256k;

         fastcgi_temp_file_write_size 256k;
         fastcgi_read_timeout 240;

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

         fastcgi_index index.php;


This config however always leads to "404 Not Found" errors for php files.

What am I doing wrong?

Please correct me.


More information about the nginx mailing list