温馨提示×

debian lamp怎么重启

小樊
37
2026-09-10 18:29:24
栏目: 智能运维

在 Debian 上“重启 LAMP”通常是指重启 Apache + MySQL/MariaDB + PHP(PHP 一般不需要单独重启,除非改了 PHP 配置)。下面按常见情况给你说明。


一、重启 Apache

sudo systemctl restart apache2

查看状态:

sudo systemctl status apache2

二、重启 MySQL / MariaDB

先确认你用的是哪个:

sudo systemctl status mysql
# 或
sudo systemctl status mariadb

如果是 MySQL

sudo systemctl restart mysql

如果是 MariaDB

sudo systemctl restart mariadb

三、一次性重启 LAMP(Apache + 数据库)

sudo systemctl restart apache2
sudo systemctl restart mysql
# 或
sudo systemctl restart mariadb

四、重启 PHP(仅改了 php.ini 时需要)

PHP 一般随 Apache 一起生效(mod_php),重启 Apache 即可。

如果是 PHP-FPM:

sudo systemctl restart php-fpm
# 或(版本相关)
sudo systemctl restart php8.2-fpm

五、开机自启(建议确认)

sudo systemctl enable apache2
sudo systemctl enable mysql
# 或
sudo systemctl enable mariadb

如果你愿意,可以告诉我:

  • Debian 版本(如 11 / 12)
  • 用的是 MySQL 还是 MariaDB
  • 是否用了 PHP-FPM

我可以给你更精确的一条命令。

0 踩