温馨提示×

ubuntu lamp如何重启

小樊
41
2026-10-18 17:02:11
栏目: 智能运维

在 Ubuntu 上“重启 LAMP”通常指重启 Apache + MySQL/MariaDB + PHP(PHP 一般不需要单独重启)。下面按常见情况说明。


一、重启 Apache

sudo systemctl restart apache2

查看状态:

sudo systemctl status apache2

二、重启 MySQL / MariaDB

如果是 MySQL

sudo systemctl restart mysql

如果是 MariaDB

sudo systemctl restart mariadb

查看状态:

sudo systemctl status mysql
# 或
sudo systemctl status mariadb

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

sudo systemctl restart apache2
sudo systemctl restart mysql

(或 mariadb)


四、开机自启(推荐)

sudo systemctl enable apache2
sudo systemctl enable mysql

五、旧版本(SysV 方式,老系统)

如果 systemctl 不可用:

sudo service apache2 restart
sudo service mysql restart

六、确认 LAMP 是否正常运行

sudo netstat -tulnp | grep -E '80|3306'

或

curl http://localhost

如果你是想 重启整个服务器,也可以用:

sudo reboot

如果你用的是 特定 Ubuntu 版本 或 LNMP(Nginx),可以告诉我,我给你对应命令。

0 踩