0

I have been installed php-fpm and tengine centos 6.

Here is my /usr/local/nginx/conf/nginx.conf

server {
    listen       80;
    server_name  localhost;

    location / {
        root   html;
        index  index.html index.htm;

    error_page  404              /404.html;

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }

    location ~ \.php$ {
        proxy_pass   http://127.0.0.1;
    }


    location ~ \.php$ {
        root           html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
    #   fastcgi_param  SCRIPT_FILENAME/$document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    location ~ /\.ht {
        deny  all;
    }
}

http://172.104.126.251/index.html Work!

But

http://172.104.126.251/index.php can't work, it appear error page.

Hope you guys can help me, thanks!

  • do you have already running on `127.0.0.1:9000` php-fpm? You are routing php there, so, if you have no php-fpm module running, no reply will be sent. – Evhz Jul 21 '17 at 06:28
  • I type the command "service php-fpm start", it shows ok. But I type "netstat -tclpn" can't find 127.0.0.1:9000 listen. – Hsu BO Song Jul 21 '17 at 07:50
  • then try to check php-fpm config file and adjust it to be running where you like. Have a look [here](https://stackoverflow.com/q/35668008/5476782). Also there is [this](https://www.if-not-true-then-false.com/2011/nginx-and-php-fpm-configuration-and-optimizing-tips-and-tricks/) nginx article for php-fpm configuration. – Evhz Jul 21 '17 at 08:30
  • fastcgi_pass unix:/tmp/php-cgi.sock; – Hsu BO Song Jul 21 '17 at 09:07
  • 1
    Finally,I solve the problem. http://172.104.126.251/index.php it works. I am not through "9000 port" to start php-fpm, instead I through "php-cgi.sock". Thanks to Karlos. – Hsu BO Song Jul 21 '17 at 09:20
  • It works. I just use sock not port. Here are my config. location ~ \.php$ { root html; # fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /$document_root$fastcgi_script_name; fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PHP_VALUE "open_basedir=$document_root:/tmp/"; include fastcgi_params; } – Hsu BO Song Jul 21 '17 at 09:24

0 Answers0