0

I just finished installing Nginx and PHP-FPM using the steps in guide here. However, the test PHP info page seems to be downloading instead of showing up on the browser.

Here's what the config looks like:

php.ini

[root@localhost ~]# grep fix_pathinfo=  /etc/php.ini 
cgi.fix_pathinfo=0

/etc/php-fpm.d/www.conf (sections that were changed)

listen = /var/run/php-fpm/php-fpm.sock
listen.owner = nobody
listen.group = nobody
; RPM: apache Choosed to be able to access some dir as httpd
user = nginx
; RPM: Keep a group allowed to write in log dir.
group = nginx

/etc/nginx/fastcgi_params

fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;

fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  HTTPS              $https if_not_empty;

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param  REDIRECT_STATUS    200;

The run file exists:

[root@localhost ~]# file /var/run/php-fpm/php-fpm.sock 
/var/run/php-fpm/php-fpm.sock: socket

The nginx process seems up:

root      2438  0.0  0.6 327192 10056 ?        Ss   19:06   0:00 php-fpm: master process (/etc/php-fpm.conf)
nginx     2440  0.0  0.2 327192  4540 ?        S    19:06   0:00 php-fpm: pool www
nginx     2441  0.0  0.2 327192  4540 ?        S    19:06   0:00 php-fpm: pool www
nginx     2442  0.0  0.2 327192  4540 ?        S    19:06   0:00 php-fpm: pool www
nginx     2443  0.0  0.2 327192  4540 ?        S    19:06   0:00 php-fpm: pool www
nginx     2444  0.0  0.2 327192  4540 ?        S    19:06   0:00 php-fpm: pool www

Yet, the PHP file seems to be downloading instead of loading on the browser - this is a simple info page:

[root@localhost html]# pwd
/usr/share/nginx/html
[root@localhost html]# cat info.php 
<? phpinfo(); ?>
[root@localhost html]# ll info.php 
-rw-r--r--. 1 root root 17 Jul 27 19:01 info.php

In order check this further, SElinux was set to Permissive, the server was rebooted, but none of those steps worked. And normal HTML files are being served without errors from /usr/share/nginx/html

Is there some configuration/parameter/directive that I may have missed while setting this up?

rahulnair
  • 1
  • 1
  • Did you perform the changes in step four and restart nginx? – Tero Kilkanen Jul 27 '16 at 16:54
  • @TeroKilkanen: Yes, the exact same `default.conf` file was used and nginx was restarted (tried rebooting the server too). Also tried switching the `server_name` value between localhost, 127.0.0.1, the server's IP and the FQDN, none of which worked. – rahulnair Jul 28 '16 at 12:49
  • How does nginx configuration look like? – Tero Kilkanen Jul 28 '16 at 14:04

0 Answers0