A
A
AleDv2018-06-19 11:04:31
PHP
AleDv, 2018-06-19 11:04:31

How to make Nginx process PHP scripts?

This is my first time setting up an nginx server. Faced with the fact that php scripts are not processed.
Settings:

server {                                                                                                                                                                
        listen 80;                                                                                                                                                      
        server_name _;                                                                                                                                                  
                                                                                                                                                                        
        access_log /var/log/nginx/access.log;                                                                                                                           
        error_log /var/log/nginx/error.log;                                                                                                                             
                                                                                                                                                                        
        root /var/www/html;                                                                                                                                             
                                                                                                                                                                        
        index index.php;                                                                                                                                                

        location / { try_files $uri $uri/ /index.php?$args; }                                                                                                           
                                                                                                                                                                        
        location ~ \.php$ {                                                                                                                                             
                include fastcgi_params;                                                                                                                                 
                fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;                                                                                                         
                try_files $uri =404;                                                                                                                                    
        }                                                                                                                                                               
}

There are no php runtime errors in the logs. I tried a bunch of configurations for location - zero sense. Tell me what could be the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dmirogin, 2018-06-19
@dmirogin

Add to /etc/nginx/fastcgi_params

fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question