0

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 174.129.213.152/index.php
and I can access other file from my domain correctly like http://gamebiz.asia/robots.txt

The problem is when I call php file http://gamebiz.asia or http://gamebiz.asia/index.php their result in blank page.

I try change configuration from
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; to fastcgi_pass 127.0.0.1:9000; 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


Configuration

conf.d/default.conf

server{
    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;
}

sites-available/gamebiz.asia.conf

server {
    server_name  www.gamebiz.asia;
    rewrite ^(.*) http://gamebiz.asia$1 permanent;
}

server {
    listen 80;
    server_name gamebiz.asia;
    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.

4
  • try adding fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; to sites-available/gamebiz.asia.conf in php location block Jan 15, 2013 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, 2013 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, 2013 at 12:25
  • you are welcome :) Jan 15, 2013 at 15:13

1 Answer 1

0

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 gamebiz.asia; config block.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .