게시판 기능 테스트를 위해
<?php
// PHP code to handle file upload if needed
$upload_max_filesize = "your_max_filesize"; // Set your maximum file size
for ($i = 0; $i < $number_of_files; $i++) {
// Handle file upload logic here if required
}
?>
<!-- HTML and JavaScript code for automatic file detection and display -->
<script>
document.addEventListener("DOMContentLoaded", function () {
const fileInput = document.querySelectorAll('.uploadBtn');
fileInput.forEach(function (input, index) {
input.addEventListener('change', function (event) {
const fileName = event.target.files[0].name;
const fileType = fileName.split('.').pop().toLowerCase();
// Check if the file type is allowed (webm, avi, mp4)
if (['webm', 'avi', 'mp4'].includes(fileType)) {
const fileContainer = document.createElement('div');
fileContainer.innerHTML = `<p>File #${index + 1}: ${fileName}</p>`;
document.body.appendChild(fileContainer);
} else {
alert('Invalid file type. Please choose webm, avi, or mp4.');
}
});
});
});
</script>
를 테스트하던 도중 페이지가 500 Bad Gateway 에러 페이지를 출력라며 도메인 조차 정상 작동이 되지 않았다.
당황한 나는 sudo systemctl restart nginx를 했지만 여전히 작동하지 않았고
sudo systemctl stop nginx를 하니 멈췄다. 나는 nginx 자체의 문제가 아니라는 것을 직감하고
vi /var/log/nginx/error.log를 해서 오류 내용을 확인했다.
-----------------------------------------------------------------------------------------------------
2023/10/02 00:40:19 [crit] 401585#401585: *8 connect() to unix:/var/run/php/php7.4-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 40.77.167.79, server: 도메인, request: "GET /bbs/search.php?sfl=wr_subject&sop=and&stx=%C2%B0%C2%84, HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: "도메인"
2023/10/02 00:41:28 [crit] 401585#401585: *10 connect() to unix:/var/run/php/php7.4-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 52.167.144.209, server: 도메인, request: "GET /bbs/board.php?bo_table=code&wr_id=222&sst=wr_nogood&sod=asc&sop=and&page=9&device=mobile HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: "도메인"
2023/10/02 00:42:48 [crit] 401585#401585: *12 connect() to unix:/var/run/php/php7.4-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 52.167.144.234, server: 도메인, request: "GET /bbs/board.php?bo_table=code&wr_id=245&sst=wr_good&sod=asc&sop=and&page=8&c_id=247&w=c&device=pc&c_id=246&w=c HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: "도메인"
2023/10/02 00:43:15 [crit] 414459#414459: *1 connect() to unix:/var/run/php/php7.4-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 192.168.0.1, server: 도메인, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: "도메인"
2023/10/02 00:43:37 [crit] 414752#414752: *1 connect() to unix:/var/run/php/php7.4-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 192.168.0.1, server: 도메인, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: "도메인"
2023/10/02 00:43:40 [crit] 414752#414752: *3 connect() to unix:/var/run/php/php7.4-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 54.36.148.240, server: 도메인, request: "GET /bbs/sns_send.php?longurl=http%3A%2F%도메인%2Fbbs%2Fboard.php%3Fbo_table%3Dcode%26wr_id%3D321%26sst%3Dwr_good%26sod%3Dasc%26sop%3Dand%26page%3D4&title=nginx+%EC%9E%AC%EC%8B%9C%EC%9E%91%EC%9D%B4+%EC%95%88%EB%90%A0+%EB%95%8C+%7C+systemctl+restart+nginx+%EC%9E%91%EB%8F%99+%EB%B6%88%EA%B0%80+%28%EB%A6%AC%EB%88%85%EC%8A%A4+-%EC%9A%B0%EB%B6%84%ED%88%AC%29&sns=facebook HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: "도메인"
2023/10/02 00:43:44 [crit] 414752#414752: *5 connect() to unix:/var/run/php/php7.4-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 192.168.0.1, server: 도메인, request: "GET /bbs/board.php?bo_table=testt&wr_id=1&device=pc HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: "도메인", referrer: "
https://도메인/bbs/good.php?bo_table=testt&wr_id=2&good=nogood"
2023/10/02 00:44:29 [crit] 414768#414768: *1 connect() to unix:/var/run/php/php7.4-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 192.168.0.1, server: 도메인, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: "도메인"
2023/10/02 00:45:00 [crit] 414768#414768: *3 connect() to unix:/var/run/php/php7.4-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 52.167.144.209, server: 도메인, request: "GET /bbs/board.php?bo_table=code&wr_id=63&page=9&device=mobile HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: "도메인"
-----------------------------------------------------------------------------------------------------
사실 잘 모르겠고 외계어 같다.(영어 알르레기가 있는 나에게는 어려웠다)
그래서 chat gpt한테 물어보니까 php-fpm 문제라고 한다.
sudo systemctl status php7.4-fpm을 하니
-----------------------------------------------------------------------------------------------------
php7.4-fpm.service - The PHP 7.4 FastCGI Process Manager
Loaded: loaded (/lib/systemd/system/php7.4-fpm.service; enabled; vendor preset: enabled)
Active: failed (Result: oom-kill) since Mon 2023-10-02 00:36:03 KST; 10min ago
Docs: man:php-fpm7.4(8)
Main PID: 398109 (code=exited, status=0/SUCCESS)
Status: "Processes active: 0, idle: 3, Requests: 1027, slow: 0, Traffic: 0req/sec"
CPU: 50.928s
Oct 01 21:35:33 ubuntu systemd[1]: Starting The PHP 7.4 FastCGI Process Manager...
Oct 01 21:35:35 ubuntu systemd[1]: Started The PHP 7.4 FastCGI Process Manager.
Oct 02 00:35:54 ubuntu systemd[1]: php7.4-fpm.service: A process of this unit has been killed by the OOM kill>
Oct 02 00:36:03 ubuntu systemd[1]: php7.4-fpm.service: Failed with result 'oom-kill'.
Oct 02 00:36:03 ubuntu systemd[1]: php7.4-fpm.service: Consumed 50.928s CPU time.
-----------------------------------------------------------------------------------------------------
메시지가 뜨고 유독
Oct 02 00:36:03 ubuntu systemd[1]: php7.4-fpm.service: Failed with result 'oom-kill'.
라는 에러 메시지가 뻘건색이어서 다시 물어보니 메모리 부족이라고 한다.
뭐 근데 나는 메모리 최적화 하는법도 잘 모르고 메모리를 추가할 방법도 딱히 없기에
(라즈베리파이는 메모리가 납땜되어서 나온다) 그냥
[code]systemctl restart php7.4-fpm[/code]
를 하니 해결된 듯 하다.
2kat님의 댓글
2kat 아이피 (222.♡.250.95) 작성일최고입니다.