gpt4 book ai didi

php - 无法在 RHEL + nginx 上解释 PHP

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:39:29 25 4
gpt4 key购买 nike

我正在执行以下步骤,但似乎无法解释 PHP。我做了很多这样的变体,广泛地搜索了网络并将其展示给 friend :我们不明白我们做错了什么。你能帮忙吗?

  1. 启动 RHEL 7.3 Amazon 免费套餐实例
  2. 使用 Mac 终端应用通过 SSH 连接

    sudo yum install wgetwget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpmsudo rpm -Uvh epel-release-latest-7*.rpmsudo yum install nginxsudo service nginx restart
  3. rehl实例入站规则开放80端口

  4. 检查 http://[my_instance_name].eu-central-1.compute.amazonaws.com/ , 在Fedora页面显示欢迎使用nginx

  5. 安装php并配置nginx

sudo yum install php-fpmsudo yum install nanosudo nano /etc/php.ini, and in the file, set cgi.fix_pathinfo=0sudo 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;        }    }
  1. 配置php
sudo nano /etc/php-fpm.d/www.conf and confirm user and group are php-fpmsudo service php-fpm restartsudo nano /usr/share/nginx/html/info.php containing phpinfo(); (with the php tags, stackoverflow seems to hide it)sudo service nginx restartsudo chkconfig --levels 235 nginx onsudo chkconfig --levels 235 php-fpm on
  1. 浏览到 http://[my_instance_name].eu-central-1.compute.amazonaws.com/info.php : 它下载 php 文件而不是解释它

  2. 更改步骤/etc/php-fpm.d/www.conf 并说用户和组是 nginx,重新启动 nginx,php 文件仍然下载而不是解释

  3. 更改步骤/etc/nginx/conf.d/default.conf 并说 server_name = [我的实例的 IP],重新启动 nginx,php 文件仍然下载而不是解释

我错过了什么?

最佳答案

首先检查/var/log/nginx 和/var/log/php-fpm 的日志

其次,使用 netstat -lnp 检查 php-fpm 是否监听端口 9000

第三,这是适合我的 nginx 配置:

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

关于php - 无法在 RHEL + nginx 上解释 PHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44442218/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com