温馨提示×

怎样重启linux lnmp

小樊
45
2026-10-09 15:01:24
栏目: 智能运维

“重启 LNMP”通常指重启 Linux + Nginx + MySQL(MariaDB) + PHP 这套环境。下面按常见情况给你几种方法。


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

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

# 重启全部
lnmp restart

# 分别重启
lnmp nginx restart
lnmp mysql restart
lnmp php-fpm restart

也可以:

/etc/init.d/nginx restart
/etc/init.d/mysql restart
/etc/init.d/php-fpm restart

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

# 重启 Nginx
systemctl restart nginx

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

# 重启 PHP-FPM(版本号可能不同)
systemctl restart php-fpm
# 或
systemctl restart php7.4-fpm

三、只重启某个服务(推荐)

一般不建议全重启,哪里有问题重启哪里:

  • 网站打不开 → 重启 Nginx
  • 数据库连不上 → 重启 MySQL
  • PHP 页面异常 → 重启 PHP-FPM

四、确认服务状态

systemctl status nginx
systemctl status mysqld
systemctl status php-fpm

五、常见排错命令

# 查看 Nginx 错误
tail -f /usr/local/nginx/logs/error.log

# 查看 PHP 错误
tail -f /usr/local/php/var/log/php-fpm.log

如果你能告诉我:

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

我可以给你更精确的重启/修复方案。

0 踩