- 在/var/www/下新建站点文件,例如/var/www/test.com
- 编辑配置文件,
vi /etc/nginx/sites-available/default
,添加server,如下:server{ listen 80; listen [::]:80; server_name test.com; root /var/www/test.com; index index.html; location /{ try_files $uri $uri/ =404; } #添加php解析 location ~ .php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php7.3-fpm.sock; } }
- 添加证书,能https访问:
certbot --authenticator webroot --webroot-path /var/www/test.com/ --installer nginx -d test.com域名