安裝nginx
sudo apt install nginx
安裝php
sudo apt install php7.2
配置nginx虛擬主機
server
{
listen 80;
server_name api.example.com;
index index.php index.html;
root /www/wwwroot;
location / {
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php/$1 last;
}
}
location ~* \.php$ {
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
}