楠木大叔 2023-01-29 09:22 采纳率: 0%
浏览 15

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 内容:

<?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日志 没有访问到,也没有日志。

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

但是总是不成功。

  • 写回答

3条回答 默认 最新

  • 梦想橡皮擦 优质创作者: python技术领域 2023-01-29 10:08
    关注

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

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

    评论

报告相同问题?

问题事件

  • 创建了问题 1月29日