在Debian上安装LNMP可参考以下步骤:
sudo apt update
,sudo apt upgrade -y
。sudo apt install nginx -y
,然后启动并设置开机自启:sudo systemctl start nginx
,sudo systemctl enable nginx
。sudo apt install mariadb-server mariadb-client -y
,安装时设置root密码,之后启动并设置开机自启:sudo systemctl start mariadb
,sudo systemctl enable mariadb
,运行sudo mysql_secure_installation
进行安全配置。sudo apt install php-fpm php-mysql -y
,根据需要安装其他扩展,启动PHP-FPM并设置开机自启:sudo systemctl start php7.4-fpm
,sudo systemctl enable php7.4-fpm
(版本号根据实际调整)。/etc/nginx/sites-available/default
,在location ~ \.php$
部分添加include snippets/fastcgi-php.conf
和fastcgi_pass unix:/run/php/php7.4-fpm.sock
等配置,测试配置后重启Nginx:sudo nginx -t
,sudo systemctl reload nginx
。/var/www/html
目录下创建info.php
文件,内容为<?php phpinfo(); ?>
,在浏览器中访问服务器IP或域名加上/info.php
,查看PHP信息页面。