微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

php 9000端口没有启动怎么办

PHP 9000端口没有启动的解决办法:1、找到“PHP5/fpm/pool.d/www.conf”;2、将listen改为“127.0.0.1:9000”;3、将Nginx改回用端口监听的方式;4、重启NginxPHP-fpm即可。

本文操作环境:ubuntu 16.04系统、PHP7.1版、DELL G3电脑

PHP 9000端口没有启动怎么办?PHP-fpm启动以后,没有出现9000端口?

最近在复现一个PHP扩展的后门,需要搭建Nginx+PHP环境,Nginx我是用源码裸装的,不带任何第三方模块。

PHP-cli和PHP-fpm 则是通过ubuntu的标准apt-get命令安装的。

随后需要修改NginxNginx.conf文件让其支持PHP脚本解析。

查询网上的配置有两种,一种是

支持127.0.0.1:9000

location ~ \.PHP$ {
    root           html;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.PHP;
    fastcgi_param  SCRIPT_FILENAME   /usr/local/Nginx/html/$fastcgi_script_name;
    include        fastcgi_params;
}

另一种是使用sock文件

location ~ .PHP$ {
        root           /usr/share/Nginx/html;
        fastcgi_pass   unix:/var/run/PHP-fpm/PHP5-fpm.sock;
        fastcgi_index  index.PHP;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

刚开始使用第一种9000端口的方式进行配置,PHP解析不了,后经过查询PHP-fpm日志,发现有sock

[17-Sep-2019 00:23:02] NOTICE: fpm is running, pid 5617
[17-Sep-2019 00:23:02] NOTICE: ready to handle connections
[17-Sep-2019 00:23:02] NOTICE: systemd monitor interval set to 10000ms
[17-Sep-2019 00:31:28] ERROR: An another FPM instance seems to already listen on /var/run/PHP5-fpm.sock
[17-Sep-2019 00:31:28] ERROR: FPM initialization Failed
[17-Sep-2019 00:37:34] NOTICE: configuration file /etc/PHP5/fpm/PHP-fpm.conf test is successful

随后在Nginx配置文件中改用第二种sock文件交互的模式,发现还是页面解析不了。

最后找到/etc/PHP5/fpm/pool.d/www.conf 配置文件,将listen改为127.0.0.1:9000

又将Nginx改回用端口监听的方式,重启NginxPHP-fpm以后,终于可以解析PHP脚本了。。

root@ubuntu:/usr/local/Nginx# netstat -tln
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN     
tcp        0      0 127.0.1.1:53            0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN     
tcp6       0      0 ::1:631                 :::*                    LISTEN     
root@ubuntu:/usr/local/Nginx# pgrep Nginx|xargs kill -s 9
root@ubuntu:/usr/local/Nginx# vim conf/Nginx.conf
root@ubuntu:/usr/local/Nginx# sbin/Nginx 
root@ubuntu:/usr/local/Nginx#

Nginx.conf配置文件

 server {
        listen       80;
        server_name  localhost;
        root   html;
        index  index.PHP;
        location ~\.PHP$ {
            fastcgi_pass  127.0.0.1:9000;
            fastcgi_index index.PHP;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }

/etc/PHP5/fpm/pool.d/www.conf文件修改的地方:

; The address on which to accept FastCGI requests.
; Valid Syntaxes are:
;   'ip.add.re.ss:port'    - to listen on a TCP socket to a specific address on
;                            a specific port;
;   'port'                 - to listen on a TCP socket to all addresses on a
;                            specific port;
;   '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = 127.0.0.1:9000

在这里插入图片描述

推荐学习:《PHP教程

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐