티스토리 뷰

Linux

nginx - php-fpm 연동

CHOMAN 2019. 5. 16. 09:39

참고 사이트

https://forteleaf.tistory.com/entry/nginx-php71-phpfpm-%EC%84%A4%EC%B9%98%ED%95%98%EA%B8%B0
https://www.hostinger.com/tutorials/how-to-install-lemp-centos7

테스트 환경

CentOS7
php 7.3.5 버전
nginx 1.12.2

nginx 설치

특별한 저장소 필요

yum install epel-release
yum install nginx

php-fpm 설치

yum install php-fpm

기본저장소 외에 PHP 패키지 종류 및 버전은 따로 설치가 필요하다

nginx 설정

vim /etc/nginx/conf.d/default.conf (파일생성)

server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  도메인이나 아이피;

        location / {
        root /home/homepage;
        index index.php index.html;
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }

        location ~ \.php$ {
            root           /home/ns7;
#            fastcgi_pass   127.0.0.1:9000;
            fastcgi_pass unix:/var/run/php-fpm/www.sock;
            fastcgi_index  index.php;
#            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }


    }
  • apache 같이 설정 파일을 별도 conf.d/ 하위에 넣어줘도 되고 /etc/nginx/*.conf 에 있는 파일을 직접 수정해도 가능하다

php-fpm 설정

vim /etc/php-fpm.conf

여기는 아마 딱히 건들일게 없다?

vim /etc/php-fpm.d/www.conf

user = nginx
group = nginx
listen = /var/run/php-fpm/www.sock
listen.owner = nginx
listen.group = nginx
security.limit_extensions = .php .php3 .php4 .php5 .php7 .html .htm .inc

구동

systemctl start nginx
systemctl start php-fpm
  • 아마 nginx (80) 으로 받아서 소켓으로 백그라운드 php-fpm 으로 넘겨서 처리하는 방식이지 싶다?

'Linux' 카테고리의 다른 글

ntp (time.google.com)  (0) 2019.05.28
nginx conf 설정  (0) 2019.05.17
telnet 통신 테스트  (0) 2019.04.02
gitlab 설치  (0) 2019.03.22
proc 정보  (0) 2019.03.22
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함