Hello.

There are two hosts. At first I installed nginx, I request index.html - it returns, everything works.

I installed php on the second host (using sudo apt-get install php-fpm php-mysql).

Nginx code:

server { listen 443; ssl on; ssl_certificate /etc/ssl/xxxx.com.crt; ssl_certificate_key /etc/ssl/xxxx.com.key; root /var/www/xxxx.com/html; index index.html index.htm index.nginx-debian.html; server_name xxxx.com www.xxxx.com; location / { try_files $uri $uri/ =404; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass xxx.xxx.xxx.xx:9000; #ip второго хоста на котором установлен php #include fastcgi_params; #fastcgi_index index.php; #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #fastcgi_param QUERY_STRING $query_string; } } server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; server_name xxxx.com www.xxxx.com; return 301 https://xxxx.com; } 

In the /etc/php/7.0/fpm/pool.d/www.conf file on the second host, replace the line listen = /run/php/php7.0-fpm.sock with listen = XXX.XXX.XXX.XX: 9000 ( where X is the Ip of the same host). I also tried to write listen = 127.0.0.1:9000.

In the folder with the site on the first host I add the Index.php file in it, displaying the string Hello World. However, the page does not open and gives 504 error after about 30 seconds.

Ping both hosts from each other normally. What can be wrong? Thank.

  • check that the tcp connection is established: $ telnet XXX.XXX.XXX.XX 9000 . ru.stackoverflow.com/q/541021/178576 - aleksandr barakin
  • If you execute this command on a host on which php is installed, it displays Trying XXX.XXX.XXX.XX Connected XXX.XXX.XXX.XX Escape character is '^]'. Connection closed by foreign host. If I execute this command from the host on which nginx (but the IP address is the same, that is, the host on which php) then writes: Trying XXX.XXX.XXX.XX ... and that's it. - FirstName LastName
  • here and deal with it, but not with (I quote tags) nginx, php, php-fpm, fastcgi. which are in no way related to the lack of communication. - aleksandr barakin
  • Can you give more details? The port 9000 is listened to, no errors are written to the log, in any manual for setting up nginx on the same host, and php-fpm on the other did not come across anything like that, everywhere the same thing - on the nginx side, specify fastcgi_pass XXX.XXX.XXX.XX : 9000, on the php side, listen on this port, that's all. - FirstName LastName
  • once again: the lack of communication between your two computers has nothing to do with either nginx or php-fpm. - aleksandr barakin

0