Server
CLI로 서버 문제를 빠르게 진단
바로가기 →
$ ssh kosuni@server
Welcome to Ubuntu 22.04 LTS (GNU/Linux 6.x)
$ sudo tail -n 50 /var/log/nginx/error.log
2026/01/29 10:12:41 [error] upstream timed out while reading response header ...
2026/01/29 10:12:42 [warn] client sent too large body: 15728640 bytes ...
$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
$ sudo systemctl restart php7.4-fpm
$ curl -I https://example.com
HTTP/2 200
PHP
실무에서 자주 터지는 문제, 짧게 해결
바로가기 →
<?php
declare(strict_types=1);
require __DIR__ . '/api/_db.php';
require __DIR__ . '/api/_auth.php';
function h(string $s): string {
return htmlspecialchars($s, ENT_QUOTES, 'UTF-8');
}
$id = (int)($_GET['id'] ?? 0);
if ($id <= 0) {
http_response_code(404);
echo '<script>alert("This page does not exist.");location.href="/";</script>';
exit;
}
$stmt = $pdo->prepare("SELECT * FROM posts WHERE id=:id LIMIT 1");
$stmt->execute([':id' => $id]);
$post = $stmt->fetch(PDO::FETCH_ASSOC) ?: null;
?>
Database
느린 쿼리/인덱스/백업까지 실전 노트
바로가기 →
-- slow query quick check
EXPLAIN SELECT id, title, published_at
FROM posts
WHERE status = 1 AND board = 'server'
ORDER BY published_at DESC
LIMIT 20;
-- index tune
ALTER TABLE posts
ADD INDEX idx_board_status_published (board, status, published_at);
-- backup
mysqldump -u root -p kosuni posts boards > backup_2026-01-29.sql