sudo apt-get update 

sudo apt-get install -y language-pack-en-base

locale-gen en_US.UTF-8



sudo apt-get install software-properties-common 

sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php

sudo apt-get update 



sudo apt-get -y install php7.1

sudo apt-get -y install php7.1-mysql

sudo apt-get install php7.1-fpm


apt-get install php7.1-curl php7.1-xml php7.1-mcrypt php7.1-json php7.1-gd php7.1-mbstring



sudo apt-get -y install nginx


sudo apt-get -y install mysql-server-5.6


原文链接:https://www.cnblogs.com/php-linux/p/6016439.html


nginx 配置文件:


server {

       listen 80;

       listen [::]:80;


       server_name abc.cn;


       root /var/www/abc_cn;

       index index.html index.php;


location / {

         try_files $uri $uri/ /index.php?$query_string;



       }

        location ~ \.php$ {

            include snippets/fastcgi-php.conf;

            fastcgi_pass unix:/run/php/php7.1-fpm.sock;

        }

}


因为复制之前的配置文件,使用的是fastcgi_pass unix:/run/php/php7.0-fpm.sock;,导致出现502错误,和访问php文件直接下载了,把7.0换成7.1后,就解决了。


如果出现500错误,就是权限问题


chmod -R 777 .