Ubuntu LNMP搭建步骤如下:
sudo apt update && sudo apt upgrade -y。sudo apt install nginx -y,启动并设置开机自启:sudo systemctl start nginx,sudo systemctl enable nginx。sudo apt install mysql-server -y,运行安全脚本:sudo mysql_secure_installation。sudo apt install php-fpm php-mysql -y,启动并设置开机自启:sudo systemctl start php-fpm,sudo systemctl enable php-fpm。/etc/nginx/sites-available/default,在server块中添加location ~ \.php$相关配置,fastcgi_pass指向正确的PHP - FPM套接字文件,如unix:/var/run/php/php7.4 - fpm.sock。sudo nginx -t,无错误后重启Nginx:sudo systemctl restart nginx。/var/www/html目录下创建info.php文件,内容为<?php phpinfo(); ?>,在浏览器中访问http://服务器IP/info.php,查看PHP信息页面确认搭建成功。