温馨提示×

centos lamp怎么重启

小樊
42
2026-09-30 09:38:24
栏目: 智能运维

在 CentOS 上“重启 LAMP”一般是指重启 Apache、MySQL(MariaDB)、PHP 相关服务。下面分几种常见情况说明。


一、CentOS 6 及以前(使用 service 命令)

# 重启 Apache
service httpd restart

# 重启 MySQL / MariaDB
service mysqld restart
# 或
service mariadb restart

# PHP 一般不需要单独重启(作为 Apache 模块时随 Apache 重启)

二、CentOS 7 / 8(使用 systemctl,推荐)

# 重启 Apache
systemctl restart httpd

# 重启 MySQL / MariaDB
systemctl restart mysqld
# 或
systemctl restart mariadb

查看状态:

systemctl status httpd
systemctl status mariadb

三、一次性重启整个 LAMP(示例)

systemctl restart httpd
systemctl restart mariadb

四、如果你是用 LNMP 一键包(非系统自带)

常见命令:

lnmp restart

或

/etc/init.d/nginx restart
/etc/init.d/mysql restart

五、确认服务是否开机启动(可选)

systemctl enable httpd
systemctl enable mariadb

如果你能告诉我:

  • CentOS 版本(6 / 7 / 8)
  • 用的是 Apache 还是 Nginx
  • MySQL 还是 MariaDB

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

0 踩