温馨提示×

LNMP Debian怎么重启

小樊
42
2026-09-01 20:42:37
栏目: 智能运维

Debian 下的 LNMP(Linux + Nginx + MySQL/MariaDB + PHP) 环境,重启方式取决于你是 源码安装APT 安装,还是使用了 LNMP 一键包。下面按常见情况说明:


一、使用 LNMP 一键安装包(最常用)

如果你是用 LNMP.org 一键包安装的:

# 重启所有服务
lnmp restart

# 单独重启
lnmp nginx restart
lnmp mysql restart
lnmp php-fpm restart

二、Debian 使用 APT 安装(systemd 方式)

1️⃣ 重启 Nginx

systemctl restart nginx

2️⃣ 重启 MySQL / MariaDB

# MySQL
systemctl restart mysql

# 或 MariaDB
systemctl restart mariadb

3️⃣ 重启 PHP-FPM

先确认 PHP 版本(如 7.4、8.1):

systemctl restart php7.4-fpm
# 或
systemctl restart php8.1-fpm

4️⃣ 一键重启全部

systemctl restart nginx mysql php8.1-fpm

三、源码编译安装(无 systemd)

Nginx

/usr/local/nginx/sbin/nginx -s reload
# 或
service nginx restart

MySQL

/etc/init.d/mysql restart

PHP-FPM

/etc/init.d/php-fpm restart

四、查看服务状态(排错用)

systemctl status nginx
systemctl status mysql
systemctl status php8.1-fpm

五、常见建议

  • ✅ 修改配置后优先用 reload(不中断服务)
  • ✅ 真正更新版本或卡死才用 restart
  • ❌ 不要同时多次 restart,避免端口占用

如果你能告诉我:

  • Debian 版本(如 11 / 12)
  • LNMP 安装方式(一键包 / apt / 源码)

我可以给你完全对应的一条命令

0