C
C
Carry2017-09-19 15:35:28
PHP
Carry, 2017-09-19 15:35:28

Debian 9 + nginx + php-fpm what's the problem?

Tell me what could be the problem:
Debian 9.0 is installed on the cloud
1. Installed according to the instructions for PHP 7 ( https://github.com/kasparsd/php-7-debian)
2. Installed according to the instructions for Nginx 1.13.5 ( https:// gist.github.com/tollmanz/8662688)
The problem is that php files do not work, writes 502 Bad Gateway. The site on pure html works.
Initially, the php7-fpm.sock file was not created. I created it manually:

python -c "import socket as s; sock = s.socket(s.AF_UNIX); sock.bind('/run/php7-fpm.sock')"

The configs are:
PHP
Config /usr/local/php7/etc/php-fpm.d/www.conf
[www]
user = www-data
group = www-data
listen = /run/php7-fpm.sock
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3

I didn't change anything else in PHP....
NGINX
/etc/nginx/nginx.conf

user www-data;
worker_processes 4;
worker_rlimit_nofile 200000;
pid /var/run/nginx.pid;
events {
worker_connections 4000;
use epoll;
 multi_accept on;
}
http {
       charset utf-8;
        open_file_cache max=200000 inactive=20s; 
        open_file_cache_valid 30s; 
        open_file_cache_min_uses 2;
        open_file_cache_errors on;
  sendfile on;
  tcp_nopush on;
  tcp_nodelay on;
  keepalive_timeout 30;
  keepalive_requests 1000;
  reset_timedout_connection on;
  client_body_timeout 10;
  send_timeout 2;
  types_hash_max_size 2048;
  server_names_hash_bucket_size 64;
  include /etc/nginx/mime.types;
  default_type application/octet-stream;
  error_log /var/log/nginx/error.log crit; #логирование только крит. ошибок
  gzip on;
  gzip_disable "msie6";
  gzip_min_length 10240;
        gzip_proxied expired no-cache no-store private auth;
        gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml;
  include /etc/nginx/sites-enabled/*;
  upstream php7-fpm-sock {
        server unix:/run/php7-fpm.sock;
}
}


/etc/nginx/sites-enabled/test.com

server {
        listen  80;
  charset utf-8;
        server_name  test.com test.com;
        root   /var/www/test.com;
        index  index.php;
    
location ~ /\. {
deny all;
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~ \.php$ {
    try_files $uri =404;
     fastcgi_split_path_info ^(.+\.php)(/.+)$;
    # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
    fastcgi_pass php7-fpm-sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME /var/www$fastcgi_script_name;
    fastcgi_param DOCUMENT_ROOT /var/www;
     # send bad requests to 404
    fastcgi_intercept_errors on;
    include fastcgi_params;
  }
}


Errors in the config does not issue!
Screenshots:
service nginx status

f86dd5fdfca24d99ab4932db9cf72f7b.png

service php7-fpm status

610f0474282d47cbaf515881d2f97e0d.png

netstat-tlnp

c802eab499ba4bcc950848a2285c7393.jpg

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Mukovoz, 2017-09-19
@carryx

1. Installed according to PHP 7 instructions ( https://github.com/kasparsd/php-7-debian)

Building php when it is in the Debian repositories is at least somehow stupid, especially with dubious instructions.
To be honest, you changed everything, because you installed a self-assembled version, instead of installing a ready-made version from the repository without crutches, with the ability to update. Here you first do it through the ass, and then ask what's wrong.
yes, of course, everything can work in this configuration option, but you complicate your life. In this case, it doesn't work for you because of the incorrect setting of this directive
https://nginx.ru/ru/docs/http/ngx_http_fastcgi_mod...
In your case, it should look like this
. But read the link to the documentation anyway.

N
nikolayvaganov, 2017-09-19
@nikolayvaganov

Why is upstream called - php7-fpm-sock , but connected as fastcgi_pass php; ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question