在 Debian 上,“LNMP”一般指 Linux + Nginx + MySQL(MariaDB) + PHP。启动 LNMP 实际就是分别启动 Nginx、MySQL/MariaDB、PHP-FPM 这几个服务。下面按常见情况说明。
sudo systemctl start nginx
sudo systemctl enable nginx # 开机自启
检查状态:
sudo systemctl status nginx
sudo systemctl start mariadb
sudo systemctl enable mariadb
sudo systemctl start mysql
sudo systemctl enable mysql
检查状态:
sudo systemctl status mariadb
# 或
sudo systemctl status mysql
先确认 PHP 版本,例如:
php -v
假设是 PHP 8.2:
sudo systemctl start php8.2-fpm
sudo systemctl enable php8.2-fpm
其他版本示例:
sudo systemctl start php7.4-fpm
检查状态:
sudo systemctl status php8.2-fpm
sudo systemctl start nginx mariadb php8.2-fpm
ss -lntp | grep nginx
mysql -u root -p
在 /var/www/html 创建 info.php:
<?php
phpinfo();
访问:
http://服务器IP/info.php
sudo ss -lntp
常见冲突:Apache(80 端口)
检查:
ls /run/php/
并确认 Nginx 配置中的:
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
sudo service nginx start
sudo service mariadb start
sudo service php8.2-fpm start
如果你愿意,我可以:
直接贴你的 Debian 版本:
cat /etc/debian_version