PHP nginx 설정

Jinseok Lee·2020년 6월 18일
1
post-thumbnail

사연

과거에 PHP로 구현한 서비스를 다른 쪽 서버로 이관하는 와중에 nginx 설정을 하였는데 잃어버리지 않고자 간단하게 남겨놓으려고함. 이전에 사용하던 aws 서버에서는 apache서버를 사용했는데 nginx로 이관하면서 여러가지 시행착오가 있었다. PHP 정말 오랜만이다 ㅠㅠ

nginx 설정 파일

server {
	listen       80;
        server_name  example.com;
        root /var/www/html;
        index  index.php index.html index.htm;

        location / {
                try_files $uri $uri/ /index.php;
        }

        location ~* \.php$ {
                fastcgi_pass unix:var/run/php/php7.2-fpm.sock;
                # include       fastcgi_params;
                include fastcgi.conf;
        }
}

위와 같은 내용을 /etc/nginx/site-availables/default에 추가해주니까 잘 되었다.

기타

  • 사전에 php가 설치되어 있어야 한다.
  • unix:var/run/php/php7.2-fpm.sock; 이 부분은 php설치경로나 버전에 따라서 달라질 수 있다.
  • root 경로도 프로젝트 경로에 따라서 달라질 수 있다.
profile
전 위메프, 이직준비중

0개의 댓글