1、更新软件源
sudo apt-get update
sudo apt-get upgrade
2、安装Nginx
sudo apt-get install nginx
3、启动Nginx
sudo systemctl start nginx
4、安装Php7.3
sudo apt-get install php7.3-fpm
5、配置Nginx,使其支持Php
sudo nano /etc/nginx/sites-enabled/default
代码修改如下
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.php index.html index.htm;
server_name _;
location / {
try_files $uri /index.php$is_args$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
6、每次修改配置后都需要重新加载Nginx,使配置生效
sudo systemctl reload nginx
7、创建index.php
sudo nano /var/www/html/index.php
加入代码如下:
<?php
phpinfo();
?>