nginx+php-fpm搭建网站服务器端口映射不能访问

nginx+php-fpm搭建网站服务器端口映射不能访问

服务器环境: centos 7
php: 8.0.27

img

php-fpm 启动状态

img

index.php 文件路径: /var/www/html/matomo/

img

index.php 内容:

 phpinfo(); ?>

nginx 配置:

server {
     listen 9527 default_server;
     listen [::]:9527 default_server;
     root   /var/www/html/matomo; #你的站点目录,绝对路径即可
     index index.php index.html index.htm;
     server_name 52interview.com;      #网站地址
     location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            try_files $uri $uri/ =404;
    }
    location ~ \.PHP$ {
            include fastcgi.conf;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.PHP;
            fastcgi_split_path_info ^(.+\.PHP)(/.+)$;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
} 

执行命令 netstat -nap|grep fpm

img

浏览器访问:

http://www.52interview.com:9527/index.php

img

查看了nginx日志 没有访问到,也没有日志。

以上是参考网上资料做的配置

但是总是不成功。

Nginx 配置文件中 listen 指令设置的端口与实际使用的端口不一致。请检查 Nginx 配置文件,确保 listen 指令中设置的端口正确。

防火墙规则限制了对该端口的访问。请检查防火墙规则,确保允许对该端口的访问。

测试页面是最简单弄出来检查LNMP环境的正确与否。
你的nginx没看到日志?是一点日志都没有吗?没有的话,可以去设置启用日志噶。
还有你的FPM的日志都可以去查查是否有提示。
LNMP搭建的设置,你也可以参考我的博文:https://bbs.huaweicloud.com/blogs/385328


无论怎样,排查就明确配置,看日志来定位问题。