Answer the question
In order to leave comments, you need to log in
How to properly set up alias on Nginx so that php works?
I can't figure out how to set up alias on Nginx to make php work.
To make a simple alias work, it is enough to write:
location /aaa {
alias /var/www/mysite;
}
location /bb {
alias /var/www/mysite;
}
location ~* ^/bb/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
alias /var/www/mysite/$1;
}
location ~ ^/bb/(.+\.php)$ {
try_files $uri =404;
alias /var/www/mysite/$1;
fastcgi_pass backend;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
Answer the question
In order to leave comments, you need to log in
Already almost gave up, and oppachki found the solution https://stackoverflow.com/questions/28490391/how-t...
The solution looks like this:
location /bb {
alias /var/www/mysite;
location ~ ^/bb/(.+\.php)$ {
fastcgi_pass backend;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename ;
include fastcgi_params;
}
}
If I understand your wish correctly, then it could be:
...
location /aaaa {
root /var/www/aaaa;
index index.php index.html index.htm;
location ~ (.+\.php)$ {
try_files $uri = 404;
root /var/www/aaaa/;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/lib/php5-fpm/aaaa.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question