可直接使用apt安装
apt update apt install nginx apt install php7.4-fpm php7.4-curl php7.4-gd php7.4-mysql
安装的软件版本是 nginx 1.18,php是7.4
额外配置
修改php-fpm配置文件/etc/php/7.4/fpm/pool.d/www.conf,改监听端口
;listen = /run/php/php7.4-fpm.sock listen = 0.0.0.0:9000
在/etc/nginx/conf.d
下新建default.conf
,表示默认站点,文件内容
server { listen 80; listen [::]:80; server_name localhost 127.0.0.1; access_log /var/log/nginx/host.access.log; location / { root /var/www/html; index index.php index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { root /var/www/html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi.conf; } }
保存,重启nginx。