Nginx with php-fastcgi - connection to

Sorry I'm missing something obvious, but I've thoroughly followed through this guide on setting up LEMP stack, but when I do open any of the pages it just initiates download of .php file I would normally access on the page, and the file itself is renamed to a string of 8 random alphanumeric symbols, with extension stripped.

2 Replies

It sounds to me like PHP isn't being executed on the server. Start by confirming that you installed the PHP handler, and configured Nginx to utilize it.

@alexfornuto:

It sounds to me like PHP isn't being executed on the server. Start by confirming that you installed the PHP handler, and configured Nginx to utilize it.
Yes, those both are done, I double checked it right now.

After reading a bit more, I added following code

location ~ \.php$ {
    try_files $uri =404;
    include /etc/nginx/fastcgi_params;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME /var/www/test.example.com/public_html$fastcgi_script_name;
    }

to my /etc/nginx/conf.d/test.example.com.conf and now I get error 404 when I attempt to load any page.

Edit: Resolved with following /etc/nginx/conf.d/test.example.com.conf

server {
listen  80;
listen 443 default ssl;

server_name test.example.com;
root  /var/www/test.example.com/public_html;

access_log /var/www/test.example.com/logs/access.log;
error_log /var/www/test.example.com/logs/error.log;

location / {
    try_files $uri $uri/ /index.php;
    }

location ~ \.php$ {
    try_files $uri =404;
    include /etc/nginx/fastcgi_params;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct