在 Debian + LNMP(Linux + Nginx + MySQL/MariaDB + PHP) 环境下,重启一般是对 Nginx、MySQL/MariaDB、PHP-FPM 分别操作。下面给你最常用、最稳妥的方法。
sudo systemctl restart nginx
查看状态:
sudo systemctl status nginx
Debian 常见的是 MariaDB,命令通用:
sudo systemctl restart mariadb
如果是 MySQL:
sudo systemctl restart mysql
查看状态:
sudo systemctl status mariadb
# 或
sudo systemctl status mysql
先确认 PHP 版本(例如 7.4、8.1、8.2):
php -v
常见重启命令:
sudo systemctl restart php8.2-fpm
如果不确定服务名:
systemctl list-units | grep php
如果你不想记那么多,可以这样:
sudo systemctl restart nginx
sudo systemctl restart mariadb
sudo systemctl restart php8.2-fpm
如果只是改了配置:
sudo systemctl reload nginx
sudo systemctl reload php8.2-fpm
sudo service nginx restart
sudo service mariadb restart
sudo service php8.2-fpm restart
Nginx 启动失败:
sudo nginx -t
PHP 不生效:
sudo systemctl status php8.2-fpm
如果你愿意,可以告诉我:
我可以给你更精确的命令 ✅