一、安装源
apt install python-software-properties -y
apt install software-properties-common python-software-properties
LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
apt update
二、安装php5.6
apt install php5.6 php5.6-fpm php5.6-mysql php5.6-gd php5.6-mbstring php5.6-curl php5.6-soap php5.6-redis php5.6-xml php5.6-apcu php5.6-mcrypt php5.6-zip -y
三、创建站点文件及php测试文件
1、mkdir -p /www/test
2、vim /www/test/info.php
输入内容
<?php phpinfo();
四、修改nginx配置文件
http{
listen 80;
root /usr/share/nginx/html;
index index.html index.htm index.nginx-debian.html;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php5.6-fpm.sock;
}
}
问题一, 502
查看nginx
日志
cat /var/log/nginx/error.log
2020/05/08 00:30:31 [crit] 29878#29878: *42 connect() to unix:/run/php/php5.6-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 172.17.0.1, server: , request: "GET /install/index.php?act=install_2 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php5.6-fpm.sock:", host: "127.0.0.1", referrer: "http://127.0.0.1/install/index.php?act=install_3"
nginx 配置文件中
php5.6-fpm.sock
文件的位置,可以通过find / -name php5.6-fpm.sock
查找。
找不到php5.6-fpm.sock
文件需要重启php5.6-fpm
, 命令service php5.6-fpm restart