标签:fail cells 进程管理 site index.php engine 配置 fpm 开始
回归正题,测试一下环境,papapa输入127.0.0.1,走你~
然后Nginx就调皮了:503 Bad Gateway(无效网关)。
叔叔要查监控了哦!老司机开上Terminal,跑到监控室:cd /var/log/nginx,看小视频:sudo vi error.log ,最赤鸡的情节是这样的:
|
1
|
2016/12/25 22:45:18 [error] 13153#13153: *1 connect() failed (111: Connection refused) while connecting to upstream, client: ::1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost:8080" |
Nginx处理请求是通过fpm 管理fastcgi来实现请求和相应,而Nginx和php-fpm可以通过监听9000端口(default)或者socket来实现。127.0.0.1:9000走网络,通过Nginx的conf文件,把php结尾的都交给9000端口处理,php-fpm(fastcgi的进程管理器)选择并且连接到一个fastcgi子进程,并将环境变量和标准输入发送到fastcgi子进程,然后不断处理请求响应。socket文件不走网络,是套接字。
php7默认的是socket,按照之前Nginx的conf文件,俩字:没毛病,才怪。(说好了在咖啡厅见,你却偏偏跑到了小树林)
老司机要潜水了:
|
1
2
3
4
5
6
7
8
9
10
11
|
cd /etc/php/7.0/fpm sudo vim php-fpm.conf发现最后:include=/etc/php/7.0/fpm/pool.d/*.conf按照上面的线索继续找cd /etc/php/7.0/fpm/pool.dll之后发现只有一个www.confsudo vim www.conf找了一下发现listen = /run/php/php7.0-fpm.sock; listen = 127.0.0.1:9000 |
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
server { listen 8080; listen [::]:8080; server_name localhost; root /home/moma/vien/learn/php/demo01/; index index.html index.htm index.php; location / { try_files $uri $uri/ /index.php$is_args$args; } location ~ \.php$ { try_files $uri =404; include fastcgi.conf; # fastcgi_pass 127.0.0.1:9000; # 换成socket fastcgi_pass unix:/run/php/php7.0-fpm.sock; #change by me fastcgi_index index.php; fastcgi_intercept_errors on; #fastcgi_param SCRIPT_FILENAME /home/gittest/$fastcgi_script_name; include fastcgi_params; }} |
OK
然后127.0.0.1:8080走你~
标签:fail cells 进程管理 site index.php engine 配置 fpm 开始
原文地址:https://www.cnblogs.com/shenwenkai/p/9295929.html