R
R
run1822019-09-24 00:36:33
PHP
run182, 2019-09-24 00:36:33

Why does nginx download php scripts?

I tried different tips from different forums, nothing helps, the scripts are still downloaded and that's it, the server and nginx restarted - all the same. What could be the problem? The config changed in different ways, changed the location, what can I try to do?
nginx.conf:

user  nginx;
worker_processes  1;
error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;
events {
    worker_connections  1024;
}
http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    access_log  /var/log/nginx/access.log  main;
    sendfile        on;
    keepalive_timeout  65;
    include /etc/nginx/conf.d/*.conf;
}

default.conf:
server {
    listen       80;
    server_name  localhost;
    location / {
        root   /usr/share/nginx/html;
        index  index.html;
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}

www.conf:
[www]
user = nginx
group = nginx
listen = /var/run/php-fpm/php-fpm.sock
listen.mode = 0660
listen.owner = nginx
listen.group = nginx
listen.allowed_clients = 127.0.0.1
pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
php_admin_value[error_log] = /var/log/php-fpm/www-error.log
php_admin_flag[log_errors] = on
php_value[session.save_handler] = files
php_value[session.save_path]    = /var/lib/php/session
php_value[soap.wsdl_cache_dir]  = /var/lib/php/wsdlcache

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
run182, 2019-09-24
@run182

added to default:

location ~ \.php$ {
    try_files $uri =404;
    fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
  }

K
ky0, 2019-09-24
@ky0

Because in your config there is nothing about processing PHP files. Add it to default.confand it will work.

A
Alexey Dmitriev, 2019-09-24
@SignFinder

and nginx also needs an engine that will process php. So you still need to install php-fpm, configure and run.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question