Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Server run on Amazon Linux AMI** (similary to redhat)

I follow the installation from Install PHP-FPM, Nginx, & MySQL on EC2 with Amazon Linux AMI

It's work properly if I call directly from server IP address like
and I can access other file from my domain correctly like

The problem is when I call php file or their result in blank page.

I try change configuration from
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; to fastcgi_pass; and fastcgi_pass localhost:9000;

the result when I call php file is "502 Bad Gateway" and If I remove fastcgi_pass I got "download" file instead of execute php file



    location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml|mp3|ogg|wav|aac)$ {
        access_log        off;
        log_not_found     off;
        expires           max;
    location ~* \.php$ {
        fastcgi_index   index.php;
        fastcgi_pass    unix:/var/run/php-fpm/php-fpm.sock;
        include /etc/nginx/fastcgi_params;
        fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
        fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
    server_tokens off;


server {
    rewrite ^(.*)$1 permanent;

server {
    listen 80;
    root   /var/www/html/SpotDiff/Release;
    index index.php index.html;

    location ~ \.php$ {
        fastcgi_pass    unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index index.php;
        include /etc/nginx/fastcgi_params;

I try config virtual host and sub-domain follow Installing NGINX and PHP-FPM - Setup for NGINX

they said I need to setup the different UNIX Sockets for PHP-FPM in /etc/php5/fpm/pool.d/

Unfortunately Amazon Linux AMI don't have apt-get and I don't have directory /etc/php5/fpm/pool.d/ and I search for pool.d but don't know how to get this file and directory.

I end up on change fastcgi_pass from unix:/var/run/php5-fpm/DOMAINNAME.socket; to my default unix:/var/run/php-fpm/php-fpm.sock; but still got blank page

Please help me I struggle with this for 3 whole days. I will appreciate any kind of help. Thank you.

share|improve this question
try adding fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; to sites-available/ in php location block – Andrei Mikhaltsov Jan 15 '13 at 11:23
sorry I can't change that for now because now my php-fpm config is broken too. Thank so much. – hsgu Jan 15 '13 at 11:42
great!!! it's work thank you so much so much sooo muchhhhh~~. please answer and I'll accept your answer. – hsgu Jan 15 '13 at 12:25
you are welcome :) – Andrei Mikhaltsov Jan 15 '13 at 15:13
up vote 0 down vote accepted

Seems you are missing

 fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
 fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;

from the config of server_name; config block.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.