Laravel 운영 명령어 정리 (실전 기준)¶
운영 서버에서 실제 사용하는 Laravel 운영 명령만 정리함. 모든 명령은 의도와 영향 범위를 이해한 상태에서 실행해야 함.
1. 서비스 상태 확인 (기본)¶
sudo systemctl status nginx
sudo systemctl status php-fpm
sudo systemctl status supervisord
sudo supervisorctl status
장애 대응 시작점은 항상 상태 확인임.
2. Nginx / PHP-FPM 반영 명령¶
설정 문법 검증:
sudo nginx -t
sudo php-fpm -t
안전 반영:
sudo systemctl reload nginx
sudo systemctl restart php-fpm
운영 기준:
- 문법 검증 없이
restart하지 않음 - 단순 설정 반영은
reload우선
3. Supervisor Worker 제어¶
상태 확인:
sudo supervisorctl status
재시작/중지/시작:
sudo supervisorctl restart laravel-worker:*
sudo supervisorctl stop laravel-worker:*
sudo supervisorctl start laravel-worker:*
설정 변경 반영:
sudo supervisorctl reread
sudo supervisorctl update
4. Queue 관련 Artisan 명령¶
cd /var/www/[ProjectName]/current
php artisan queue:restart
php artisan queue:failed
php artisan queue:retry all
php artisan queue:flush
운영 기준:
queue:restart는 배포 후 기본 절차queue:flush는 실패 원인 파악 후 제한적으로 사용
5. Scheduler 관련 명령¶
cd /var/www/[ProjectName]/current
php artisan schedule:list
php artisan schedule:run
crontab -l
운영 기준:
schedule:run수동 실행은 진단용- 실제 운영은 cron 자동 트리거 기준
6. 캐시 관련 명령¶
cd /var/www/[ProjectName]/current
php artisan config:clear
php artisan route:clear
php artisan view:clear
php artisan cache:clear
php artisan config:cache
php artisan route:cache
php artisan view:cache
운영 기준:
- clear 후 cache 재생성까지 한 세트
- 설정 변경 후 캐시 미재생성 상태로 운영하지 않음
7. 로그 확인 명령¶
tail -n 200 /var/www/[ProjectName]/current/storage/logs/laravel.log
sudo tail -n 200 /var/log/nginx/error.log
sudo tail -n 200 /var/log/php-fpm/www-error.log
sudo tail -n 200 /var/log/supervisor/laravel-worker.log
systemd 로그 확인:
sudo journalctl -u php-fpm -n 100 --no-pager
sudo journalctl -u supervisord -n 100 --no-pager
8. 잘못 쓰면 사고 나는 명령 (주의)¶
8.1 php artisan serve (운영 금지)¶
php artisan serve
- 개발 서버 실행 방식이므로 운영 기준 위반
8.2 /var/www/.../current에서 composer install (운영 금지)¶
cd /var/www/[ProjectName]/current
composer install
- 운영 상태 오염, 재현성 붕괴, 롤백 어려움
8.3 전체 권한 777 부여 (운영 금지)¶
chmod -R 777 /var/www/[ProjectName]/current
- 보안 모델 붕괴, 감사 실패 가능성 증가
9. 운영 명령 사용 원칙 요약¶
| 작업 | 권장 명령 |
|---|---|
| 서비스 상태 확인 | systemctl status, supervisorctl status |
| 설정 반영 | nginx -t 후 reload/restart |
| Queue 반영 | php artisan queue:restart |
| 캐시 반영 | clear + cache 세트 |
| 로그 확인 | tail, journalctl |
10. 정리¶
- 운영 명령은
상태 확인 → 원인 확인 → 최소 변경순서로 수행함 - 즉흥 조치보다 재현 가능한 표준 명령 세트를 우선함