温馨提示×

linux lnmp如何重启

小樊
51
2026-09-15 20:55:30
栏目: 智能运维

在 Linux 的 LNMP(Linux + Nginx + MySQL/MariaDB + PHP) 环境中,“重启”通常分为整体重启和单独重启某个服务。下面按常见发行版说明。


一、使用系统自带服务管理(推荐)

1. 单独重启各服务

Nginx

# CentOS 7+/Ubuntu/Debian
systemctl restart nginx

# 查看状态
systemctl status nginx

MySQL / MariaDB

systemctl restart mysqld     # MySQL
# 或
systemctl restart mariadb    # MariaDB

PHP-FPM

# PHP 版本不同,服务名可能不同
systemctl restart php-fpm
# 或
systemctl restart php7.4-fpm
systemctl restart php8.1-fpm

2. 一次性重启 LNMP(手动)

systemctl restart nginx
systemctl restart mysqld
systemctl restart php-fpm

二、使用 LNMP 一键安装包(非常常见)

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

lnmp restart          # 重启所有
lnmp nginx restart
lnmp mysql restart
lnmp php-fpm restart

其他命令:

lnmp start
lnmp stop
lnmp status

三、老旧系统(SysVinit)

如果是老服务器(无 systemd):

service nginx restart
service mysql restart
service php-fpm restart

四、重启前建议

  1. 检查配置是否正确
nginx -t
  1. 查看错误日志
tail -n 50 /var/log/nginx/error.log
journalctl -xe

五、常见场景

  • 改了 Nginx 配置 → 只需 restart nginx
  • 改了 PHP 代码/配置 → 重启 php-fpm
  • 数据库连不上 → 重启 mysql/mariadb
  • 整站异常 → lnmp restart

如果你能告诉我:

  • 系统版本(CentOS / Ubuntu / Debian)
  • 是否用 LNMP 一键包
  • 具体想重启哪个服务

我可以给你精确命令。

0 踩