I have an Nginx HTTP server with PHP-FPM set up and almost everything works fine. I want to be able to go to path/to/file
and it give me index.php?url=path/to/file
, which it does. However, it downloads the actual PHP, it won't execute it in the browser. I'm not sure what is causing this.
Nginx configuration:
server {
listen 80;
server_name sandbox.domain.tld;
access_log /path/to/domain/log/sandbox.access.log;
error_log /path/to/domain/log/sandbox.error.log;
location / {
root /path/to/sandbox;
index index.php;
if (!-e $request_filename) {
rewrite ^/beta/(.+)$ /beta/index.php?url=$1 break;
}
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include /usr/local/nginx/conf/fastcgi_params;
fastcgi_param SCRIPT_FILENAME /path/to/sandbox$fastcgi_script_name;
}
Try changing
rewrite ^/beta/(.+)$ /beta/index.php?url=$1 break;
to
rewrite ^/beta/(.+)$ /beta/index.php?url=$1 last; break;
Which should get nginx to re-read the URI and process it accordingly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With