0

I cannot run any PHP script on my nginx server.

I set up the usual nginx+PHP infrastructure, following this tutorial How To Install Linux, Nginx, MySQL, PHP (LEMP stack) in Ubuntu 16.04 .

The usual test <?php phpinfo(); ?> returns correctly all the PHP conf stuff. But when I try anything else, even a simple echo "something" I only get a blank page.

EDIT: here it is the code, it couldn't be more trivial.

<html>
 <head>
  <title>Test PHP</title>
 </head>
 <body>
 <?php echo "Hello World!<p>"; ?>
 </body>
</html>

So I digged a bit into the logs:

The nginx/error.log says:

2018/12/18 17:49:32 [error] 2126#2126: *17 upstream timed out (110: Connection timed out) while reading upstream, client: ::1, server: _, request: "GET /hello.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "localhost"

the php-fpm.log is even less explanatory:

[18-Dec-2018 16:27:11] NOTICE: fpm is running, pid 1754

[18-Dec-2018 16:27:11] NOTICE: ready to handle connections

[18-Dec-2018 16:27:11] NOTICE: systemd monitor interval set to 10000ms

I've installed xdebug in order to try to catch any possible hanging point, but it completes correctly to me.

here it is the default

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    root /var/www/html;
    index index.php index.html index.htm index.nginx-debian.html;
    server_name _;
    location / {
            try_files $uri $uri/ =404;
    }
    location ~ \.php$ {
            include snippets/fastcgi-php.conf;

            fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    }
    location ~ /\.ht {
            deny all;
    }
}

I've read other post where the same problem is observed, but I exclude I've exeeded the max number of connections.

I runned out of ideas, any clue?

Thanks in advance.

  • 1
    Please show the PHP file that you tried to call that isn't working. – Michael Hampton Dec 18 '18 at 18:22
  • I temporarily used the workaround to replace nginx with apache: now it works. So it seems that nginx was misconfigured, I still wonder how. – Daniele Dec 19 '18 at 9:08

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.