温馨提示×

linux lamp怎么重启

小樊
40
2026-10-09 14:43:22
栏目: 智能运维

在 Linux 下“重启 LAMP”一般是指重启 Linux + Apache + MySQL(MariaDB) + PHP 这套环境。不同发行版命令略有不同,下面按常见系统说明。


一、Debian / Ubuntu(Apache + MySQL/MariaDB)

1. 重启 Apache

sudo systemctl restart apache2

2. 重启 MySQL / MariaDB

sudo systemctl restart mysql
# 或
sudo systemctl restart mariadb

3. 一键重启 LAMP(分开执行即可)

sudo systemctl restart apache2
sudo systemctl restart mysql

二、CentOS / RHEL / Rocky / AlmaLinux

1. 重启 Apache

sudo systemctl restart httpd

2. 重启 MySQL / MariaDB

sudo systemctl restart mysqld
# 或
sudo systemctl restart mariadb

三、查看服务状态

systemctl status apache2   # Ubuntu
systemctl status httpd     # CentOS
systemctl status mysql

四、如果你用的是 LNMP 一键包(如 lnmp.org)

lnmp restart

或单独:

lnmp apache restart
lnmp mysql restart

五、老系统(SysVinit,无 systemctl)

service apache2 restart
service httpd restart
service mysql restart

如果你能告诉我:

  • Linux 发行版(Ubuntu / CentOS / Debian?)
  • Apache 还是 Nginx?
  • MySQL 还是 MariaDB?

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

0 踩