温馨提示×

linux laravel怎么重启服务

小樊
41
2026-09-25 11:42:48
栏目: 智能运维

在 Linux + Laravel 环境下,“重启服务”通常要看你用的是哪种运行方式。下面按常见情况说明:


一、使用 PHP 内置开发服务器(php artisan serve)

# 先结束旧进程
pkill -f "artisan serve"

# 重新启动
php artisan serve

或指定端口:

php artisan serve --host=0.0.0.0 --port=8000

二、使用 Nginx + PHP-FPM(最常见)

1. 重启 PHP-FPM

# 查看 PHP 版本
php -v

# 例如 PHP 8.1
sudo systemctl restart php8.1-fpm

2. 重启 Nginx

sudo systemctl restart nginx

3. 清 Laravel 缓存(强烈建议)

php artisan config:clear
php artisan cache:clear
php artisan route:clear
php artisan view:clear

三、使用 Apache + PHP

sudo systemctl restart apache2

四、使用 Supervisor 管理队列 / 常驻进程

如果你是跑 队列、WebSocket、定时任务:

sudo supervisorctl restart all
# 或单个
sudo supervisorctl restart laravel-worker

五、Laravel Octane(Swoole / RoadRunner)

php artisan octane:stop
php artisan octane:start

六、Docker 环境

docker-compose restart
# 或
docker-compose restart php nginx

七、常见排错

  • 改了 .env → 必须:
php artisan config:clear
  • 报错 500 → 看日志:
tail -f storage/logs/laravel.log

如果你能告诉我:

  • 用的是 Nginx / Apache / Docker
  • 是否用了 队列 / Octane / Supervisor

我可以给你更精确的重启命令。

0 踩