我正在执行以下步骤,似乎无法解释PHP . 我做了很多变种,在网上广泛搜索并向朋友展示:我们不明白我们做错了什么 . 你能帮忙吗?
-
启动RHEL 7.3 Amazon免费层实例
-
使用MAC终端应用程序在SSH中连接
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
-
在rehl实例入站规则中打开端口80
-
检查http://[my_instance_name].eu-central-1.compute.amazonaws.com/,它在Fedora页面上显示对nginx的欢迎
-
安装php并配置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;
}
}
- 配置php
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
-
浏览到http://[my_instance_name].eu-central-1.compute.amazonaws.com/info.php:它下载php文件而不是解释它
-
更改步骤/etc/php-fpm.d/www.conf并说用户和组是nginx,重启nginx,php文件仍然下载而不是解释
-
更改步骤/etc/nginx/conf.d/default.conf并说server_name = [我的实例的IP],重启nginx,php文件仍然下载而不是解释
我错过了什么?
2 回答
首先检查/ var / log / nginx和/ var / log / php-fpm中的日志
其次,使用
netstat -lnp
检查php-fpm是否在端口9000上侦听第三,这是适合我的nginx配置:
你使用短的PHP开放标签,
<?
?如果是这样,请仔细检查php.ini中的short_open_tag
是否已启用,因为在某些发行版中默认情况下未启用它 .它可能是它实际/正在/工作,但PHP没有看到任何'PHP代码' .