Nginx + PHP FastCGI 연동 (Windows)

2020. 6. 17. 16:39카테고리 없음

1. Nginx 설치

http://nginx.org/en/download.html

 * 실행 위치에 압축 풀기 (ex : C:\nginx)

 

2. PHP 설치

 * 메인 사이트에서는 최신 버전(현재 7.2~7.4)만 있으므로 아래링크로 들어가서 원하는 버전 받기.

https://windows.php.net/downloads/releases/archives/

 

3. Nginx + PHP FastCGI 연동

 * nginx.conf 파일 설정

location / {
	root	{연동시킬 서버의 디렉토리};
	fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
	fastcgi_pass	127.0.0.1:9000;
	try_files	$uri $uri/ /game.php?$args;
	include		fastcgi_params;
	index  index.php;
}

 * service로 등록

    - RunHiddenConsole 프로그램으로 서비스 등록

    - 프로그램 다운 받고 적당한 위치에 압축해제 (프로그램 삭제되면 서비스 실행안됨)

      https://redmine.lighttpd.net/attachments/660/RunHiddenConsole.zip   

    - Install service 클릭하면 서비스 등록 됨.

    - 같은 방법으로 nginx도 서비스 등록 (nginx는 Arugments 없어도 됨)

    - \HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\PHPFastCGI 서비스 실행 시 설정값 바꾸고 싶으면 regedit 들어가서 설정 바꾸면 됨. (해당레지스트 없으면 nssm.exe 로 검색)