学习 Debian + LNMP(Linux + Nginx + MySQL/MariaDB + PHP) 可以从「基础环境 → 安装配置 → 实战优化」循序渐进。下面给你一套清晰的学习路线。
apt update && apt upgrade
systemctl status nginx
journalctl -u nginx
/etc/nginx,/var/www)apt install ufw
ufw allow 22,80,443
ufw enable
apt install nginx
systemctl enable --now nginx
访问服务器 IP,看到 Nginx 欢迎页即成功。
apt install mariadb-server
mysql_secure_installation
创建数据库示例:
CREATE DATABASE testdb;
CREATE USER 'testuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON testdb.* TO 'testuser'@'localhost';
FLUSH PRIVILEGES;
apt install php-fpm php-mysql php-cli
检查版本:
php -v
编辑站点配置:
nano /etc/nginx/sites-available/default
关键配置:
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php-fpm.sock;
}
测试 PHP:
echo "<?php phpinfo(); ?>" > /var/www/html/info.php
apt install certbot python3-certbot-nginx
certbot --nginx
tail -f /var/log/nginx/error.log
如果你愿意,我可以:
你想从哪一步开始?