티스토리 뷰

Backend/Server

CentOS 8 + nginx 1.17.8 + php 7.4.3

out of coding 2020. 2. 22. 23:12

nginx : 1.17.8, php : 7.4.3 이렇게 설치하였습니다.

 

기타 버전은 안될수도 있으니 유의 바랍니다.:D

 

1. dnf remi 저장소 install

https://rpms.remirepo.net/

 

Remi's RPM repository

Download mirrors - Full content AM: http://remi.mirrors.arminco.com/ - full mirror (Armenia, IPv4, IPv6) AU: http://remi.conetix.com.au/ - full mirror (Australia, IPv4) AU: https://remi.mirror.digitalpacific.com.au/ - full mirror (Australia, IPv4, IPv6, rs

rpms.remirepo.net

이런곳이 있는데요. Core CentOS와 RedHat Enterprise Linux의 최신 버전의 소프트웨어를 제공하고 있습니다.

대충 이래요. ㅎㅎ

$ sudo dnf install dnf-utils http://rpms.remirepo.net/enterprise/remi-release-8.rpm

받아줍니다.

 

 

2. 사용가능한 목록을 조회

$ sudo dnf module list php

 

3. 저는 7.4를 선택하여서 다음과 같이 진행했습니다.

$ sudo dnf module reset php
$ sudo dnf module enable php:remi-7.4

 

4. Install PHP

$ sudo dnf install php php-opcache php-gd php-curl php-mysqlnd

 

5. 부팅시에 php-fpm이 실행되도록

$ sudo systemctl enable --now php-fpm

 

6. nginx 설치. 이전에 제가 작업해둔 문서를 참조해주세요.

2019/12/24 - [Web/Server] - Nginx 설치하기. 저는 CentOS에서 했어요.

 

Nginx 설치하기. 저는 CentOS에서 했어요.

yum을 이용하여 설치를 합니다. 설치 방법은 공식 사이트에 자세하게 나와 있으니 그걸 참조하셔도 됩니다. ^^ Stable Link : http://nginx.org/en/linux_packages.html#stable CentOS : http://nginx.org/en/linu..

mrgamza.tistory.com

 

7. php-fpm www.conf 파일 수정

$ sudo vi /etc/php-fpm.d/www.conf

내용들중에 다음을 수정합니다.

user = nginx
group = nginx
listen = /var/run/php-fpm/php-fpm.sock
listen.owner = nginx
listen.group = nginx

라인들중에 위의 부분들을 찾아서 수정합니다.

 

8. nginx default.conf 파일 수정

$ sudo vi /etc/nginx/conf.d/default.conf

이런 형태로 만들어 줍니다.

server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;

    root   /usr/share/nginx/html;
    index  index.php index.html index.htm;

    location / {
        try_files $uri $uri/ =404;
    }

    error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page  500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    location ~ \.php$ {
        try_files       $uri =404;
        fastcgi_pass    unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index   index.php;
        fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include         fastcgi_params;
    }

9. Test

$ sudo vi /usr/share/nginx/html/index.php

 다음 내용을 넣어줍니다.

<?php
phpinfo();
?>

http://localhost 하게 되면 다음과 비슷한 화면이 나오면 성공한겁니다.

 

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
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
글 보관함