温馨提示×

怎么重启linux lnmp服务

小樊
38
2026-09-09 16:58:59
栏目: 智能运维

Linux + LNMP(Linux + Nginx + MySQL/MariaDB + PHP) 环境下,**“重启 LNMP 服务”**通常包含 Nginx、MySQL、PHP-FPM 三个服务。下面按常见情况说明:


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

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

lnmp restart

仅重启某个服务:

lnmp nginx restart
lnmp mysql restart
lnmp php-fpm restart

二、使用 systemctl(CentOS 7+/Ubuntu 16.04+)

1. 重启 Nginx

systemctl restart nginx

2. 重启 MySQL / MariaDB

systemctl restart mysql
# 或
systemctl restart mariadb

3. 重启 PHP-FPM

systemctl restart php-fpm
# 如果版本不同,例如 PHP 7.4
systemctl restart php7.4-fpm

一次性重启 LNMP

systemctl restart nginx mysql php-fpm

三、使用 service(老版本系统)

service nginx restart
service mysql restart
service php-fpm restart

四、只重载配置(不中断服务)

如果你只是修改了配置文件:

nginx -s reload
systemctl reload php-fpm
systemctl reload mysql

五、常用检查命令

systemctl status nginx
systemctl status mysql
systemctl status php-fpm

六、排错建议

如果重启失败,先看日志:

journalctl -xe
cat /var/log/nginx/error.log

如果你告诉我:

  • 系统版本(CentOS / Ubuntu / Debian)
  • 是否用 LNMP 一键包
  • PHP 版本

我可以给你最准确的一条命令

0