Reputation: 85
I'm doing the following steps and can't seem to have the PHP interpreted. I've done many variants of this, searched the web extensively and shown it to a friend: we don't understand what we do wrong. Could you help?
Connect in SSH with mac Terminal app
sudo yum install wget wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm sudo rpm -Uvh epel-release-latest-7*.rpm sudo yum install nginx sudo service nginx restart
open port 80 in rehl instance inbound rules
check http://[my_instance_name].eu-central-1.compute.amazonaws.com/, it displays the welcome to nginx on Fedora page
install php and configure nginx
sudo yum install php-fpm sudo yum install nano sudo nano /etc/php.ini, and in the file, set cgi.fix_pathinfo=0 sudo nano /etc/nginx/nginx.conf, and set the worker processes to 4 (value was: auto) sudo nano /etc/nginx/conf.d/default.conf and have the following conf: server { listen 80; server_name localhost; location / { root /usr/share/nginx/html; index index.php index.html index.htm; } error_page 404 /404.html; location = /404.html { root /usr/share/nginx/html; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { root /usr/share/nginx/html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
sudo nano /etc/php-fpm.d/www.conf and confirm user and group are php-fpm sudo service php-fpm restart sudo nano /usr/share/nginx/html/info.php containing phpinfo(); (with the php tags, stackoverflow seems to hide it) sudo service nginx restart sudo chkconfig --levels 235 nginx on sudo chkconfig --levels 235 php-fpm on
browse to http://[my_instance_name].eu-central-1.compute.amazonaws.com/info.php : it downloads the php file instead of interpreting it
change step /etc/php-fpm.d/www.conf and say that user and group are nginx, restart nginx, php file still downloaded instead of interpreted
change step /etc/nginx/conf.d/default.conf and say server_name = [IP of my instance], restart nginx, php file still downloaded instead of interpreted
What am I missing?
Upvotes: 1
Views: 556
Reputation: 103
Are you using the short php open tags,<?
? If so, double check that short_open_tag
in your php.ini is enabled, as it's not enabled by default on some distributions.
It might be that it actually /is/ working, but that PHP is not seeing any 'php code'.
Upvotes: 0
Reputation: 998
First of all check logs at /var/log/nginx and /var/log/php-fpm
Second, Check using netstat -lnp
that php-fpm do listen on port 9000
Third, This is the nginx configuration that works for me:
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+\.php)(/.*)$;
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
include fastcgi_params;
}
Upvotes: 2