sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update
安装PHP7.2和通用扩展:
sudo apt install php7.2 php7.2-fpm php7.2-mysql php-common php7.2-cli php7.2-common php7.2-json php7.2-opcache php7.2-readline php7.2-mbstring php7.2-xml php7.2-gd php7.2-curl
启动PHP7.2-FPM:
sudo systemctl start php7.2-fpm
系统自启动:
sudo systemctl enable php7.2-fpm
检查其状态:
systemctl status php7.2-fpm
vi /etc/nginx/conf.d/default.conf
server {
listen 80;
listen [::]:80;
server_name att.cool;
root /usr/share/nginx/html/;
index index.php index.html index.htm index.nginx-debian.html;
location / {
try_files $uri $uri/ /index.php;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ .php$ {
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
include snippets/fastcgi-php.conf;
}
location ~ /.ht {
deny all;
}
}