温馨提示×

linux lnmp怎么重启

小樊
43
2026-08-21 10:59:52
栏目: 智能运维

LNMP(Linux + Nginx + MySQL/MariaDB + PHP) 环境下,“重启”一般是指分别重启 Nginx、MySQL、PHP-FPM。下面按常见情况给你总结。


一、通用 systemd 方式(推荐,适用于 CentOS 7+/Ubuntu 16.04+)

1️⃣ 重启 Nginx

systemctl restart nginx

2️⃣ 重启 MySQL / MariaDB

systemctl restart mysqld

systemctl restart mariadb

3️⃣ 重启 PHP-FPM

根据 PHP 版本不同,例如:

systemctl restart php-fpm

systemctl restart php7.4-fpm
systemctl restart php8.1-fpm

一次性重启 LNMP(手动)

systemctl restart nginx mysqld php-fpm

二、使用 service 命令(老系统)

service nginx restart
service mysqld restart
service php-fpm restart

三、LNMP 一键安装包(军哥 LNMP)

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

lnmp restart

也可以单独重启:

lnmp nginx restart
lnmp mysql restart
lnmp php-fpm restart

四、常见问题排查

1️⃣ 查看服务状态

systemctl status nginx
systemctl status mysqld
systemctl status php-fpm

2️⃣ 配置文件改错导致重启失败

nginx -t
php-fpm -t

3️⃣ 端口被占用

ss -lntp

五、推荐重启顺序(稳妥)

systemctl restart mysql
systemctl restart php-fpm
systemctl restart nginx

如果你愿意,可以告诉我:

  • 系统版本(CentOS / Ubuntu)
  • 是否使用 lnmp.org 一键包
  • 报错信息

我可以给你更精确的命令 ✅

0