Nginx 서버에서 FastCGI를 이용하여 PHP 설정하기.
필요 패키지 설치 (Arch linux 기준)
- sudo pacman -S php
- sudo pacman -S php-fpm
- sudo pacman -S php-sqlite
/etc/php/php.ini 수정
open_basedir = list_base_directories_which_contain_PHP_files
- uncomment
extension=sqlite3.so
extension=openssl.so
extension=sqlite3.so는 php-fpm을 위해 필요하다.
extension=openssl.so는 https로 요청을 보낼 때 필요하다.
nginx.conf
http{
server{
location ~ \.php$ {
root /root_directory_of_php;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# fastcgi_pass 127.0.0.1:8050;
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
include fastcgi.conf;
fastcgi_param DOCUMENT_ROOT /root_directory_of_php/inilite_php;
include fastcgi_params;
}
}
}
nginx 설정 오류 확인
sudo nginx -t
참조
https://wiki.archlinux.org/index.php/nginx#PHP_implementationhttp://www.sitepoint.com/setting-up-php-behind-nginx-with-fastcgi/
by 月風