토요일에 할 일이 없어서 yii2를 설치해서 배포하려고 했는데, 설치 과정에서는 문제가 없었는데, nginx로 배포할 때 502 불량 게이트웨이 문제가 발생해서 오래 걸렸습니다. 그것을 고칠 시간입니다. 이 문제는 이전에 yii2를 배포할 때 겪어보지 못한 문제이므로 참고용으로 여기에 기록해 둡니다.
1. 설치 및 배포 환경
운영체제: macOS, php 버전: 5.6, nginx 버전: 1.10.1, yii2 버전: 2.0.
2, yii2 설치
yii2 설치는 매우 간단합니다. 공식 홈페이지의 매뉴얼을 참고하시면 됩니다. 여기에 설치한 것은 yii2-app-advanced(Yii 2 Advanced Project Template)입니다. 프로젝트 주소는 github에 있습니다. 이에 대해서는 단계별로 설명하지 않겠습니다.
3. nginx에 yii2 배포
실제로 yii2-app-advanced 프로젝트의 README에는 nginx에 배포하는 방법이 매우 명확하게 나와 있습니다. 단계를 따르면 문제가 없을 것입니다. 하지만 배포하는 동안 게으른 나머지 README에서 nginx 배포 매개변수를 직접 사용하여 502 잘못된 게이트웨이 오류가 발생했습니다.
HTTP 상태 코드에서 5로 시작하는 응답 코드는 모두 서버 측에서 발생하므로 nginx 로그를 살펴보세요.
오류 로그:
업스트림에서 "fastcgi: //127.0.0.1:9090"을 보니 포트가 잘못된 것 같아서 가상호스트 구성을 확인해 봤습니다.
php-fpm 구성을 살펴보겠습니다.
물론, nginx 가상 호스트에서 지정한 FastCGI 서버 수신 포트가 잘못되어 nginx가 FastCGI 서버로부터 응답을 받지 못하게 됩니다. 따라서 브라우저가 요청하면 nginx는 502 상태 코드를 브라우저에 반환하여 업스트림 FastCGI 서버가 응답하지 않았음을 브라우저에 알립니다.
4, 솔루션
nginx 가상 호스트에서 fastcgi_pass에 지정된 포트를 올바르게 수정하면 이 오류가 해결됩니다.
5, 요약
(1) HTTP 상태 코드 5로 시작하는 오류는 서버 측에서 발생합니다. 502 잘못된 게이트웨이는 요청을 실행하려는 게이트웨이 또는 프록시로 작동하는 서버(웹 서버)로 인해 발생합니다. 서버(fastcgi 서버)가 잘못된 응답을 받았습니다.
(2) fastcgi_pass는 ngx_http_fastcgi_module 모듈의 구성 지시문으로, nginx 문서에 설명되어 있는 fastcgi 서버의 주소를 지정합니다.
<span style="color: #008080;"> 1</span> <span style="color: #000000;">Syntax: fastcgi_pass address; </span><span style="color: #008080;"> 2</span> <span style="color: #0000ff;">Default</span><span style="color: #000000;">: — </span><span style="color: #008080;"> 3</span> Context: location, <span style="color: #0000ff;">if</span> <span style="color: #0000ff;">in</span><span style="color: #000000;"> location </span><span style="color: #008080;"> 4</span> <span style="color: #008080;"> 5</span> <span style="color: #000000;">Sets the address of a FastCGI server. The address can be specified as a domain name or IP address, and a port: </span><span style="color: #008080;"> 6</span> fastcgi_pass localhost:9000<span style="color: #000000;">; </span><span style="color: #008080;"> 7</span> <span style="color: #008080;"> 8</span> or as a UNIX-<span style="color: #000000;">domain socket path: </span><span style="color: #008080;"> 9</span> fastcgi_pass unix:/tmp/<span style="color: #000000;">fastcgi.socket; </span><span style="color: #008080;">10</span> <span style="color: #008080;">11</span> <span style="color: #0000ff;">If</span> a domain name resolves to several addresses, all of them will be used <span style="color: #0000ff;">in</span> a round-robin fashion. <span style="color: #0000ff;">In</span> addition, an address can be specified as a server group.
참고:
HTTP 상태 코드
fastcgi_pass
Syntax: | <strong>fastcgi_pass</strong> <code><em>address</em> ; |
---|---|
Default: | — |
Context: |
location , if in location
|

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

MinGW - Windows용 미니멀리스트 GNU
이 프로젝트는 osdn.net/projects/mingw로 마이그레이션되는 중입니다. 계속해서 그곳에서 우리를 팔로우할 수 있습니다. MinGW: GCC(GNU Compiler Collection)의 기본 Windows 포트로, 기본 Windows 애플리케이션을 구축하기 위한 무료 배포 가능 가져오기 라이브러리 및 헤더 파일로 C99 기능을 지원하는 MSVC 런타임에 대한 확장이 포함되어 있습니다. 모든 MinGW 소프트웨어는 64비트 Windows 플랫폼에서 실행될 수 있습니다.

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

에디트플러스 중국어 크랙 버전
작은 크기, 구문 강조, 코드 프롬프트 기능을 지원하지 않음

Atom Editor Mac 버전 다운로드
가장 인기 있는 오픈 소스 편집기

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경
