⭐️ Amazon Web Service/Amazon EC2

[Amazon EC2] Amazon Linux 2 - nginx(web), php-fpm(was) 설치/연동하기

mini_world 2020. 3. 27. 17:34
목차 접기

 

[nginx 서버에서 수행]

 

1. nginx 설치

[root@nginx ec2-user]# amazon-linux-extras install nginx1 -y
더보기

Installing nginx

Loaded plugins: extras_suggestions, langpacks, priorities, update-motd

Cleaning repos: amzn2-core amzn2extra-docker amzn2extra-nginx1

13 metadata files removed

6 sqlite files removed

0 metadata files removed

Loaded plugins: extras_suggestions, langpacks, priorities, update-motd

amzn2-core                                                                                          | 2.4 kB  00:00:00     

amzn2extra-docker                                                                                   | 1.8 kB  00:00:00     

amzn2extra-nginx1                                                                                   | 1.3 kB  00:00:00     

(1/6): amzn2-core/2/x86_64/updateinfo                                                               | 199 kB  00:00:00     

(2/6): amzn2-core/2/x86_64/group_gz                                                                 | 2.5 kB  00:00:00     

(3/6): amzn2extra-docker/2/x86_64/updateinfo                                                        |   69 B  00:00:00     

(4/6): amzn2extra-nginx1/2/x86_64/primary_db                                                        |  14 kB  00:00:00     

(5/6): amzn2extra-docker/2/x86_64/primary_db                                                        |  64 kB  00:00:00     

(6/6): amzn2-core/2/x86_64/primary_db                                                               |  39 MB  00:00:00     

Resolving Dependencies

--> Running transaction check

---> Package nginx.x86_64 1:1.16.1-1.amzn2.0.1 will be installed

--> Processing Dependency: nginx-filesystem = 1:1.16.1-1.amzn2.0.1 for package: 1:nginx-1.16.1-1.amzn2.0.1.x86_64

--> Processing Dependency: nginx-all-modules = 1:1.16.1-1.amzn2.0.1 for package: 1:nginx-1.16.1-1.amzn2.0.1.x86_64

--> Processing Dependency: nginx-filesystem for package: 1:nginx-1.16.1-1.amzn2.0.1.x86_64

--> Processing Dependency: libprofiler.so.0()(64bit) for package: 1:nginx-1.16.1-1.amzn2.0.1.x86_64

--> Running transaction check

---> Package gperftools-libs.x86_64 0:2.6.1-1.amzn2 will be installed

---> Package nginx-all-modules.noarch 1:1.16.1-1.amzn2.0.1 will be installed

--> Processing Dependency: nginx-mod-stream = 1:1.16.1-1.amzn2.0.1 for package: 1:nginx-all-modules-1.16.1-1.amzn2.0.1.noarch

--> Processing Dependency: nginx-mod-mail = 1:1.16.1-1.amzn2.0.1 for package: 1:nginx-all-modules-1.16.1-1.amzn2.0.1.noarch

--> Processing Dependency: nginx-mod-http-xslt-filter = 1:1.16.1-1.amzn2.0.1 for package: 1:nginx-all-modules-1.16.1-1.amzn2.0.1.noarch

--> Processing Dependency: nginx-mod-http-perl = 1:1.16.1-1.amzn2.0.1 for package: 1:nginx-all-modules-1.16.1-1.amzn2.0.1.noarch

--> Processing Dependency: nginx-mod-http-image-filter = 1:1.16.1-1.amzn2.0.1 for package: 1:nginx-all-modules-1.16.1-1.amzn2.0.1.noarch

--> Processing Dependency: nginx-mod-http-geoip = 1:1.16.1-1.amzn2.0.1 for package: 1:nginx-all-modules-1.16.1-1.amzn2.0.1.noarch

---> Package nginx-filesystem.noarch 1:1.16.1-1.amzn2.0.1 will be installed

--> Running transaction check

---> Package nginx-mod-http-geoip.x86_64 1:1.16.1-1.amzn2.0.1 will be installed

---> Package nginx-mod-http-image-filter.x86_64 1:1.16.1-1.amzn2.0.1 will be installed

--> Processing Dependency: gd for package: 1:nginx-mod-http-image-filter-1.16.1-1.amzn2.0.1.x86_64

--> Processing Dependency: libgd.so.2()(64bit) for package: 1:nginx-mod-http-image-filter-1.16.1-1.amzn2.0.1.x86_64

---> Package nginx-mod-http-perl.x86_64 1:1.16.1-1.amzn2.0.1 will be installed

---> Package nginx-mod-http-xslt-filter.x86_64 1:1.16.1-1.amzn2.0.1 will be installed

--> Processing Dependency: libxslt.so.1(LIBXML2_1.0.18)(64bit) for package: 1:nginx-mod-http-xslt-filter-1.16.1-1.amzn2.0.1.x86_64

--> Processing Dependency: libxslt.so.1(LIBXML2_1.0.11)(64bit) for package: 1:nginx-mod-http-xslt-filter-1.16.1-1.amzn2.0.1.x86_64

--> Processing Dependency: libxslt.so.1()(64bit) for package: 1:nginx-mod-http-xslt-filter-1.16.1-1.amzn2.0.1.x86_64

--> Processing Dependency: libexslt.so.0()(64bit) for package: 1:nginx-mod-http-xslt-filter-1.16.1-1.amzn2.0.1.x86_64

---> Package nginx-mod-mail.x86_64 1:1.16.1-1.amzn2.0.1 will be installed

---> Package nginx-mod-stream.x86_64 1:1.16.1-1.amzn2.0.1 will be installed

--> Running transaction check

---> Package gd.x86_64 0:2.0.35-26.amzn2.0.2 will be installed

--> Processing Dependency: libpng15.so.15(PNG15_0)(64bit) for package: gd-2.0.35-26.amzn2.0.2.x86_64

--> Processing Dependency: libpng15.so.15()(64bit) for package: gd-2.0.35-26.amzn2.0.2.x86_64

--> Processing Dependency: libfontconfig.so.1()(64bit) for package: gd-2.0.35-26.amzn2.0.2.x86_64

--> Processing Dependency: libXpm.so.4()(64bit) for package: gd-2.0.35-26.amzn2.0.2.x86_64

--> Processing Dependency: libX11.so.6()(64bit) for package: gd-2.0.35-26.amzn2.0.2.x86_64

---> Package libxslt.x86_64 0:1.1.28-5.amzn2.0.2 will be installed

--> Running transaction check

---> Package fontconfig.x86_64 0:2.10.95-11.amzn2.0.2 will be installed

--> Processing Dependency: fontpackages-filesystem for package: fontconfig-2.10.95-11.amzn2.0.2.x86_64

--> Processing Dependency: font(:lang=en) for package: fontconfig-2.10.95-11.amzn2.0.2.x86_64

---> Package libX11.x86_64 0:1.6.5-2.amzn2.0.2 will be installed

--> Processing Dependency: libX11-common >= 1.6.5-2.amzn2.0.2 for package: libX11-1.6.5-2.amzn2.0.2.x86_64

--> Processing Dependency: libxcb.so.1()(64bit) for package: libX11-1.6.5-2.amzn2.0.2.x86_64

---> Package libXpm.x86_64 0:3.5.12-1.amzn2.0.2 will be installed

---> Package libpng.x86_64 2:1.5.13-7.amzn2.0.2 will be installed

--> Running transaction check

---> Package fontpackages-filesystem.noarch 0:1.44-8.amzn2 will be installed

---> Package libX11-common.noarch 0:1.6.5-2.amzn2.0.2 will be installed

---> Package libxcb.x86_64 0:1.12-1.amzn2.0.2 will be installed

--> Processing Dependency: libXau.so.6()(64bit) for package: libxcb-1.12-1.amzn2.0.2.x86_64

---> Package stix-fonts.noarch 0:1.1.0-5.amzn2 will be installed

--> Running transaction check

---> Package libXau.x86_64 0:1.0.8-2.1.amzn2.0.2 will be installed

--> Finished Dependency Resolution

 

Dependencies Resolved

 

===========================================================================================================================

 Package                               Arch             Version                          Repository                   Size

===========================================================================================================================

Installing:

 nginx                                 x86_64           1:1.16.1-1.amzn2.0.1             amzn2extra-nginx1           556 k

Installing for dependencies:

 fontconfig                            x86_64           2.10.95-11.amzn2.0.2             amzn2-core                  231 k

 fontpackages-filesystem               noarch           1.44-8.amzn2                     amzn2-core                   10 k

 gd                                    x86_64           2.0.35-26.amzn2.0.2              amzn2-core                  147 k

 gperftools-libs                       x86_64           2.6.1-1.amzn2                    amzn2-core                  274 k

 libX11                                x86_64           1.6.5-2.amzn2.0.2                amzn2-core                  614 k

 libX11-common                         noarch           1.6.5-2.amzn2.0.2                amzn2-core                  164 k

 libXau                                x86_64           1.0.8-2.1.amzn2.0.2              amzn2-core                   29 k

 libXpm                                x86_64           3.5.12-1.amzn2.0.2               amzn2-core                   57 k

 libpng                                x86_64           2:1.5.13-7.amzn2.0.2             amzn2-core                  214 k

 libxcb                                x86_64           1.12-1.amzn2.0.2                 amzn2-core                  216 k

 libxslt                               x86_64           1.1.28-5.amzn2.0.2               amzn2-core                  243 k

 nginx-all-modules                     noarch           1:1.16.1-1.amzn2.0.1             amzn2extra-nginx1            20 k

 nginx-filesystem                      noarch           1:1.16.1-1.amzn2.0.1             amzn2extra-nginx1            21 k

 nginx-mod-http-geoip                  x86_64           1:1.16.1-1.amzn2.0.1             amzn2extra-nginx1            26 k

 nginx-mod-http-image-filter           x86_64           1:1.16.1-1.amzn2.0.1             amzn2extra-nginx1            30 k

 nginx-mod-http-perl                   x86_64           1:1.16.1-1.amzn2.0.1             amzn2extra-nginx1            39 k

 nginx-mod-http-xslt-filter            x86_64           1:1.16.1-1.amzn2.0.1             amzn2extra-nginx1            29 k

 nginx-mod-mail                        x86_64           1:1.16.1-1.amzn2.0.1             amzn2extra-nginx1            57 k

 nginx-mod-stream                      x86_64           1:1.16.1-1.amzn2.0.1             amzn2extra-nginx1            83 k

 stix-fonts                            noarch           1.1.0-5.amzn2                    amzn2-core                  1.3 M

 

Transaction Summary

===========================================================================================================================

Install  1 Package (+20 Dependent packages)

 

Total download size: 4.3 M

Installed size: 11 M

Downloading packages:

(1/21): fontpackages-filesystem-1.44-8.amzn2.noarch.rpm                                             |  10 kB  00:00:00     

(2/21): fontconfig-2.10.95-11.amzn2.0.2.x86_64.rpm                                                  | 231 kB  00:00:00     

(3/21): gd-2.0.35-26.amzn2.0.2.x86_64.rpm                                                           | 147 kB  00:00:00     

(4/21): gperftools-libs-2.6.1-1.amzn2.x86_64.rpm                                                    | 274 kB  00:00:00     

(5/21): libX11-1.6.5-2.amzn2.0.2.x86_64.rpm                                                         | 614 kB  00:00:00     

(6/21): libX11-common-1.6.5-2.amzn2.0.2.noarch.rpm                                                  | 164 kB  00:00:00     

(7/21): libXau-1.0.8-2.1.amzn2.0.2.x86_64.rpm                                                       |  29 kB  00:00:00     

(8/21): libXpm-3.5.12-1.amzn2.0.2.x86_64.rpm                                                        |  57 kB  00:00:00     

(9/21): libpng-1.5.13-7.amzn2.0.2.x86_64.rpm                                                        | 214 kB  00:00:00     

(10/21): libxcb-1.12-1.amzn2.0.2.x86_64.rpm                                                         | 216 kB  00:00:00     

(11/21): libxslt-1.1.28-5.amzn2.0.2.x86_64.rpm                                                      | 243 kB  00:00:00     

(12/21): nginx-all-modules-1.16.1-1.amzn2.0.1.noarch.rpm                                            |  20 kB  00:00:00     

(13/21): nginx-1.16.1-1.amzn2.0.1.x86_64.rpm                                                        | 556 kB  00:00:00     

(14/21): nginx-mod-http-geoip-1.16.1-1.amzn2.0.1.x86_64.rpm                                         |  26 kB  00:00:00     

(15/21): nginx-filesystem-1.16.1-1.amzn2.0.1.noarch.rpm                                             |  21 kB  00:00:00     

(16/21): nginx-mod-http-perl-1.16.1-1.amzn2.0.1.x86_64.rpm                                          |  39 kB  00:00:00     

(17/21): nginx-mod-http-image-filter-1.16.1-1.amzn2.0.1.x86_64.rpm                                  |  30 kB  00:00:00     

(18/21): nginx-mod-http-xslt-filter-1.16.1-1.amzn2.0.1.x86_64.rpm                                   |  29 kB  00:00:00     

(19/21): nginx-mod-mail-1.16.1-1.amzn2.0.1.x86_64.rpm                                               |  57 kB  00:00:00     

(20/21): nginx-mod-stream-1.16.1-1.amzn2.0.1.x86_64.rpm                                             |  83 kB  00:00:00     

(21/21): stix-fonts-1.1.0-5.amzn2.noarch.rpm                                                        | 1.3 MB  00:00:00     

---------------------------------------------------------------------------------------------------------------------------

Total                                                                                      8.9 MB/s | 4.3 MB  00:00:00     

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

  Installing : fontpackages-filesystem-1.44-8.amzn2.noarch                                                            1/21 

  Installing : stix-fonts-1.1.0-5.amzn2.noarch                                                                        2/21 

  Installing : fontconfig-2.10.95-11.amzn2.0.2.x86_64                                                                 3/21 

  Installing : 2:libpng-1.5.13-7.amzn2.0.2.x86_64                                                                     4/21 

  Installing : libX11-common-1.6.5-2.amzn2.0.2.noarch                                                                 5/21 

  Installing : libXau-1.0.8-2.1.amzn2.0.2.x86_64                                                                      6/21 

  Installing : libxcb-1.12-1.amzn2.0.2.x86_64                                                                         7/21 

  Installing : libX11-1.6.5-2.amzn2.0.2.x86_64                                                                        8/21 

  Installing : libXpm-3.5.12-1.amzn2.0.2.x86_64                                                                       9/21 

  Installing : gd-2.0.35-26.amzn2.0.2.x86_64                                                                         10/21 

  Installing : 1:nginx-filesystem-1.16.1-1.amzn2.0.1.noarch                                                          11/21 

  Installing : libxslt-1.1.28-5.amzn2.0.2.x86_64                                                                     12/21 

  Installing : gperftools-libs-2.6.1-1.amzn2.x86_64                                                                  13/21 

  Installing : 1:nginx-mod-http-geoip-1.16.1-1.amzn2.0.1.x86_64                                                      14/21 

  Installing : 1:nginx-mod-http-image-filter-1.16.1-1.amzn2.0.1.x86_64                                               15/21 

  Installing : 1:nginx-mod-http-perl-1.16.1-1.amzn2.0.1.x86_64                                                       16/21 

  Installing : 1:nginx-mod-http-xslt-filter-1.16.1-1.amzn2.0.1.x86_64                                                17/21 

  Installing : 1:nginx-mod-mail-1.16.1-1.amzn2.0.1.x86_64                                                            18/21 

  Installing : 1:nginx-1.16.1-1.amzn2.0.1.x86_64                                                                     19/21 

  Installing : 1:nginx-mod-stream-1.16.1-1.amzn2.0.1.x86_64                                                          20/21 

  Installing : 1:nginx-all-modules-1.16.1-1.amzn2.0.1.noarch                                                         21/21 

  Verifying  : 1:nginx-mod-stream-1.16.1-1.amzn2.0.1.x86_64                                                           1/21 

  Verifying  : gd-2.0.35-26.amzn2.0.2.x86_64                                                                          2/21 

  Verifying  : gperftools-libs-2.6.1-1.amzn2.x86_64                                                                   3/21 

  Verifying  : 1:nginx-mod-http-geoip-1.16.1-1.amzn2.0.1.x86_64                                                       4/21 

  Verifying  : 1:nginx-mod-http-image-filter-1.16.1-1.amzn2.0.1.x86_64                                                5/21 

  Verifying  : 1:nginx-mod-http-perl-1.16.1-1.amzn2.0.1.x86_64                                                        6/21 

  Verifying  : libxslt-1.1.28-5.amzn2.0.2.x86_64                                                                      7/21 

  Verifying  : stix-fonts-1.1.0-5.amzn2.noarch                                                                        8/21 

  Verifying  : 1:nginx-all-modules-1.16.1-1.amzn2.0.1.noarch                                                          9/21 

  Verifying  : 1:nginx-mod-http-xslt-filter-1.16.1-1.amzn2.0.1.x86_64                                                10/21 

  Verifying  : 1:nginx-1.16.1-1.amzn2.0.1.x86_64                                                                     11/21 

  Verifying  : 1:nginx-filesystem-1.16.1-1.amzn2.0.1.noarch                                                          12/21 

  Verifying  : 1:nginx-mod-mail-1.16.1-1.amzn2.0.1.x86_64                                                            13/21 

  Verifying  : libX11-1.6.5-2.amzn2.0.2.x86_64                                                                       14/21 

  Verifying  : fontpackages-filesystem-1.44-8.amzn2.noarch                                                           15/21 

  Verifying  : fontconfig-2.10.95-11.amzn2.0.2.x86_64                                                                16/21 

  Verifying  : libXau-1.0.8-2.1.amzn2.0.2.x86_64                                                                     17/21 

  Verifying  : libX11-common-1.6.5-2.amzn2.0.2.noarch                                                                18/21 

  Verifying  : libxcb-1.12-1.amzn2.0.2.x86_64                                                                        19/21 

  Verifying  : libXpm-3.5.12-1.amzn2.0.2.x86_64                                                                      20/21 

  Verifying  : 2:libpng-1.5.13-7.amzn2.0.2.x86_64                                                                    21/21 

 

Installed:

  nginx.x86_64 1:1.16.1-1.amzn2.0.1                                                                                        

 

Dependency Installed:

  fontconfig.x86_64 0:2.10.95-11.amzn2.0.2                        fontpackages-filesystem.noarch 0:1.44-8.amzn2           

  gd.x86_64 0:2.0.35-26.amzn2.0.2                                 gperftools-libs.x86_64 0:2.6.1-1.amzn2                  

  libX11.x86_64 0:1.6.5-2.amzn2.0.2                               libX11-common.noarch 0:1.6.5-2.amzn2.0.2                

  libXau.x86_64 0:1.0.8-2.1.amzn2.0.2                             libXpm.x86_64 0:3.5.12-1.amzn2.0.2                      

  libpng.x86_64 2:1.5.13-7.amzn2.0.2                              libxcb.x86_64 0:1.12-1.amzn2.0.2                        

  libxslt.x86_64 0:1.1.28-5.amzn2.0.2                             nginx-all-modules.noarch 1:1.16.1-1.amzn2.0.1           

  nginx-filesystem.noarch 1:1.16.1-1.amzn2.0.1                    nginx-mod-http-geoip.x86_64 1:1.16.1-1.amzn2.0.1        

  nginx-mod-http-image-filter.x86_64 1:1.16.1-1.amzn2.0.1         nginx-mod-http-perl.x86_64 1:1.16.1-1.amzn2.0.1         

  nginx-mod-http-xslt-filter.x86_64 1:1.16.1-1.amzn2.0.1          nginx-mod-mail.x86_64 1:1.16.1-1.amzn2.0.1              

  nginx-mod-stream.x86_64 1:1.16.1-1.amzn2.0.1                    stix-fonts.noarch 0:1.1.0-5.amzn2                       

 

Complete!

  0  ansible2                 available    \

        [ =2.4.2  =2.4.6  =2.8  =stable ]

  2  httpd_modules            available    [ =1.0  =stable ]

  3  memcached1.5             available    \

        [ =1.5.1  =1.5.16  =1.5.17 ]

  5  postgresql9.6            available    [ =9.6.6  =9.6.8 ]

  6  postgresql10             available    [ =10 ]

  8  redis4.0                 available    [ =4.0.5  =4.0.10 ]

  9  R3.4                     available    [ =3.4.3  =stable ]

 10  rust1                    available    \

        [ =1.22.1  =1.26.0  =1.26.1  =1.27.2  =1.31.0  =1.38.0 ]

 11  vim                      available    [ =8.0 ]

 13  ruby2.4                  available    \

        [ =2.4.2  =2.4.4  =2.4.7  =stable ]

 15  php7.2                   available    \

        [ =7.2.0  =7.2.4  =7.2.5  =7.2.8  =7.2.11  =7.2.13  =7.2.14

          =7.2.16  =7.2.17  =7.2.19  =7.2.21  =7.2.22  =7.2.23

          =7.2.24  =7.2.26  =stable ]

 17  lamp-mariadb10.2-php7.2  available    \

        [ =10.2.10_7.2.0  =10.2.10_7.2.4  =10.2.10_7.2.5

          =10.2.10_7.2.8  =10.2.10_7.2.11  =10.2.10_7.2.13

          =10.2.10_7.2.14  =10.2.10_7.2.16  =10.2.10_7.2.17

          =10.2.10_7.2.19  =10.2.10_7.2.22  =10.2.10_7.2.23

          =10.2.10_7.2.24  =stable ]

 18  libreoffice              available    \

        [ =5.0.6.2_15  =5.3.6.1  =stable ]

 19  gimp                     available    [ =2.8.22 ]

 20  docker=latest            enabled      \

        [ =17.12.1  =18.03.1  =18.06.1  =18.09.9  =stable ]

 21  mate-desktop1.x          available    [ =1.19.0  =1.20.0 ]

 22  GraphicsMagick1.3        available    \

        [ =1.3.29  =1.3.32  =1.3.34 ]

 23  tomcat8.5                available    \

        [ =8.5.31  =8.5.32  =8.5.38  =8.5.40  =8.5.42  =8.5.50

          =stable ]

 24  epel                     available    [ =7.11 ]

 25  testing                  available    [ =1.0 ]

 26  ecs                      available    [ =stable ]

 27  corretto8                available    \

        [ =1.8.0_192  =1.8.0_202  =1.8.0_212  =1.8.0_222  =1.8.0_232

          =1.8.0_242 ]

 28  firecracker              available    [ =0.11  =stable ]

 29  golang1.11               available    \

        [ =1.11.3  =1.11.11  =1.11.13  =stable ]

 30  squid4                   available    [ =4 ]

 31  php7.3                   available    \

        [ =7.3.2  =7.3.3  =7.3.4  =7.3.6  =7.3.8  =7.3.9  =7.3.10

          =7.3.11  =7.3.13  =stable ]

 32  lustre2.10               available    \

        [ =2.10.5  =2.10.8  =stable ]

 33  java-openjdk11           available    [ =11  =stable ]

 34  lynis                    available    [ =stable ]

 35  kernel-ng                available    [ =stable ]

 36  BCC                      available    [ =0.x ]

 37  mono                     available    [ =5.x ]

 38  nginx1=latest            enabled      [ =stable ]

 39  ruby2.6                  available    [ =2.6  =stable ]

 40  mock                     available    [ =stable ]

 41  postgresql11             available    [ =11  =stable ]

 42  php7.4                   available    [ =stable ]

 

2.  설정파일 수정 : /etc/nginx/nginx.conf

[root@nginx ec2-user]# vim /etc/nginx/nginx.conf

이대로 붙여넣기 하자 ^^..... 헤메지말고...

{php_Server_ip} 이 부분만 php-fpm 서버 아이피를 입력하세요^^.

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  _;
        root         /usr/share/nginx/html;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
        }

        location ~ \.php$ {
            fastcgi_pass {php_Server_ip}:9000;
            fastcgi_index index.php;
            include fastcgi_params;
	    root /var/wonmin_com/php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }

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

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

# Settings for a TLS enabled server.
#
#    server {
#        listen       443 ssl http2 default_server;
#        listen       [::]:443 ssl http2 default_server;
#        server_name  _;
#        root         /usr/share/nginx/html;
#
#        ssl_certificate "/etc/pki/nginx/server.crt";
#        ssl_certificate_key "/etc/pki/nginx/private/server.key";
#        ssl_session_cache shared:SSL:1m;
#        ssl_session_timeout  10m;
#        ssl_ciphers PROFILE=SYSTEM;
#        ssl_prefer_server_ciphers on;
#
#        # Load configuration files for the default server block.
#        include /etc/nginx/default.d/*.conf;
#
#        location / {
#        }
#
#        error_page 404 /404.html;
#            location = /40x.html {
#        }
#
#        error_page 500 502 503 504 /50x.html;
#            location = /50x.html {
#        }
#    }

}

 

3. 서비스 시작 및 enable

[root@nginx ec2-user]# systemctl enable nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
[root@nginx ec2-user]# systemctl restart nginx

 

 

 

[php-fpm 서버에서 수행]

1. php-fpm 설치

[root@php-fpm ec2-user]# yum install php* -y
더보기

Loaded plugins: extras_suggestions, langpacks, priorities, update-motd

amzn2-core                                                                                    | 2.4 kB  00:00:00     

Package php-mysql is obsoleted by php-mysqlnd, trying to install php-mysqlnd-5.4.16-46.amzn2.0.2.x86_64 instead

Resolving Dependencies

--> Running transaction check

---> Package php.x86_64 0:5.4.16-46.amzn2.0.2 will be installed

---> Package php-bcmath.x86_64 0:5.4.16-46.amzn2.0.2 will be installed

---> Package php-cli.x86_64 0:5.4.16-46.amzn2.0.2 will be installed

---> Package php-common.x86_64 0:5.4.16-46.amzn2.0.2 will be installed

---> Package php-dba.x86_64 0:5.4.16-46.amzn2.0.2 will be installed

---> Package php-devel.x86_64 0:5.4.16-46.amzn2.0.2 will be installed

---> Package php-embedded.x86_64 0:5.4.16-46.amzn2.0.2 will be installed

---> Package php-enchant.x86_64 0:5.4.16-46.amzn2.0.2 will be installed

---> Package php-fpm.x86_64 0:5.4.16-46.amzn2.0.2 will be installed

---> Package php-gd.x86_64 0:5.4.16-46.amzn2.0.2 will be installed

---> Package php-intl.x86_64 0:5.4.16-46.amzn2.0.2 will be installed

---> Package php-ldap.x86_64 0:5.4.16-46.amzn2.0.2 will be installed

---> Package php-mbstring.x86_64 0:5.4.16-46.amzn2.0.2 will be installed

---> Package php-mysqlnd.x86_64 0:5.4.16-46.amzn2.0.2 will be installed

---> Package php-odbc.x86_64 0:5.4.16-46.amzn2.0.2 will be installed

---> Package php-pdo.x86_64 0:5.4.16-46.amzn2.0.2 will be installed

---> Package php-pear.noarch 1:1.10.7-3.amzn2.0.1 will be installed

---> Package php-pecl-memcache.x86_64 0:3.0.8-4.amzn2 will be installed

---> Package php-pgsql.x86_64 0:5.4.16-46.amzn2.0.2 will be installed

---> Package php-process.x86_64 0:5.4.16-46.amzn2.0.2 will be installed

---> Package php-pspell.x86_64 0:5.4.16-46.amzn2.0.2 will be installed

---> Package php-recode.x86_64 0:5.4.16-46.amzn2.0.2 will be installed

---> Package php-snmp.x86_64 0:5.4.16-46.amzn2.0.2 will be installed

---> Package php-soap.x86_64 0:5.4.16-46.amzn2.0.2 will be installed

---> Package php-xml.x86_64 0:5.4.16-46.amzn2.0.2 will be installed

---> Package php-xmlrpc.x86_64 0:5.4.16-46.amzn2.0.2 will be installed

--> Finished Dependency Resolution

 

Dependencies Resolved

 

=====================================================================================================================

 Package                        Arch                Version                            Repository               Size

=====================================================================================================================

Installing:

 php                            x86_64              5.4.16-46.amzn2.0.2                amzn2-core              1.4 M

 php-bcmath                     x86_64              5.4.16-46.amzn2.0.2                amzn2-core               58 k

 php-cli                        x86_64              5.4.16-46.amzn2.0.2                amzn2-core              2.8 M

 php-common                     x86_64              5.4.16-46.amzn2.0.2                amzn2-core              563 k

 php-dba                        x86_64              5.4.16-46.amzn2.0.2                amzn2-core               56 k

 php-devel                      x86_64              5.4.16-46.amzn2.0.2                amzn2-core              602 k

 php-embedded                   x86_64              5.4.16-46.amzn2.0.2                amzn2-core              1.4 M

 php-enchant                    x86_64              5.4.16-46.amzn2.0.2                amzn2-core               43 k

 php-fpm                        x86_64              5.4.16-46.amzn2.0.2                amzn2-core              1.4 M

 php-gd                         x86_64              5.4.16-46.amzn2.0.2                amzn2-core              127 k

 php-intl                       x86_64              5.4.16-46.amzn2.0.2                amzn2-core               98 k

 php-ldap                       x86_64              5.4.16-46.amzn2.0.2                amzn2-core               53 k

 php-mbstring                   x86_64              5.4.16-46.amzn2.0.2                amzn2-core              505 k

 php-mysqlnd                    x86_64              5.4.16-46.amzn2.0.2                amzn2-core              172 k

 php-odbc                       x86_64              5.4.16-46.amzn2.0.2                amzn2-core               66 k

 php-pdo                        x86_64              5.4.16-46.amzn2.0.2                amzn2-core               98 k

 php-pear                       noarch              1:1.10.7-3.amzn2.0.1               amzn2-core              354 k

 php-pecl-memcache              x86_64              3.0.8-4.amzn2                      amzn2-core               68 k

 php-pgsql                      x86_64              5.4.16-46.amzn2.0.2                amzn2-core               85 k

 php-process                    x86_64              5.4.16-46.amzn2.0.2                amzn2-core               56 k

 php-pspell                     x86_64              5.4.16-46.amzn2.0.2                amzn2-core               42 k

 php-recode                     x86_64              5.4.16-46.amzn2.0.2                amzn2-core               39 k

 php-snmp                       x86_64              5.4.16-46.amzn2.0.2                amzn2-core               53 k

 php-soap                       x86_64              5.4.16-46.amzn2.0.2                amzn2-core              158 k

 php-xml                        x86_64              5.4.16-46.amzn2.0.2                amzn2-core              125 k

 php-xmlrpc                     x86_64              5.4.16-46.amzn2.0.2                amzn2-core               68 k

 

Transaction Summary

=====================================================================================================================

Install  26 Packages

 

Total download size: 10 M

Installed size: 36 M

Downloading packages:

(1/26): php-bcmath-5.4.16-46.amzn2.0.2.x86_64.rpm                                             |  58 kB  00:00:00     

(2/26): php-5.4.16-46.amzn2.0.2.x86_64.rpm                                                    | 1.4 MB  00:00:00     

(3/26): php-cli-5.4.16-46.amzn2.0.2.x86_64.rpm                                                | 2.8 MB  00:00:00     

(4/26): php-common-5.4.16-46.amzn2.0.2.x86_64.rpm                                             | 563 kB  00:00:00     

(5/26): php-dba-5.4.16-46.amzn2.0.2.x86_64.rpm                                                |  56 kB  00:00:00     

(6/26): php-devel-5.4.16-46.amzn2.0.2.x86_64.rpm                                              | 602 kB  00:00:00     

(7/26): php-enchant-5.4.16-46.amzn2.0.2.x86_64.rpm                                            |  43 kB  00:00:00     

(8/26): php-embedded-5.4.16-46.amzn2.0.2.x86_64.rpm                                           | 1.4 MB  00:00:00     

(9/26): php-fpm-5.4.16-46.amzn2.0.2.x86_64.rpm                                                | 1.4 MB  00:00:00     

(10/26): php-gd-5.4.16-46.amzn2.0.2.x86_64.rpm                                                | 127 kB  00:00:00     

(11/26): php-intl-5.4.16-46.amzn2.0.2.x86_64.rpm                                              |  98 kB  00:00:00     

(12/26): php-ldap-5.4.16-46.amzn2.0.2.x86_64.rpm                                              |  53 kB  00:00:00     

(13/26): php-mbstring-5.4.16-46.amzn2.0.2.x86_64.rpm                                          | 505 kB  00:00:00     

(14/26): php-mysqlnd-5.4.16-46.amzn2.0.2.x86_64.rpm                                           | 172 kB  00:00:00     

(15/26): php-odbc-5.4.16-46.amzn2.0.2.x86_64.rpm                                              |  66 kB  00:00:00     

(16/26): php-pdo-5.4.16-46.amzn2.0.2.x86_64.rpm                                               |  98 kB  00:00:00     

(17/26): php-pear-1.10.7-3.amzn2.0.1.noarch.rpm                                               | 354 kB  00:00:00     

(18/26): php-pecl-memcache-3.0.8-4.amzn2.x86_64.rpm                                           |  68 kB  00:00:00     

(19/26): php-pgsql-5.4.16-46.amzn2.0.2.x86_64.rpm                                             |  85 kB  00:00:00     

(20/26): php-process-5.4.16-46.amzn2.0.2.x86_64.rpm                                           |  56 kB  00:00:00     

(21/26): php-pspell-5.4.16-46.amzn2.0.2.x86_64.rpm                                            |  42 kB  00:00:00     

(22/26): php-recode-5.4.16-46.amzn2.0.2.x86_64.rpm                                            |  39 kB  00:00:00     

(23/26): php-snmp-5.4.16-46.amzn2.0.2.x86_64.rpm                                              |  53 kB  00:00:00     

(24/26): php-xml-5.4.16-46.amzn2.0.2.x86_64.rpm                                               | 125 kB  00:00:00     

(25/26): php-soap-5.4.16-46.amzn2.0.2.x86_64.rpm                                              | 158 kB  00:00:00     

(26/26): php-xmlrpc-5.4.16-46.amzn2.0.2.x86_64.rpm                                            |  68 kB  00:00:00     

---------------------------------------------------------------------------------------------------------------------

Total                                                                                 12 MB/s |  10 MB  00:00:00     

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

  Installing : php-common-5.4.16-46.amzn2.0.2.x86_64                                                            1/26 

  Installing : php-pdo-5.4.16-46.amzn2.0.2.x86_64                                                               2/26 

  Installing : php-cli-5.4.16-46.amzn2.0.2.x86_64                                                               3/26 

  Installing : php-process-5.4.16-46.amzn2.0.2.x86_64                                                           4/26 

  Installing : php-xml-5.4.16-46.amzn2.0.2.x86_64                                                               5/26 

  Installing : 1:php-pear-1.10.7-3.amzn2.0.1.noarch                                                             6/26 

  Installing : php-pecl-memcache-3.0.8-4.amzn2.x86_64                                                           7/26 

  Installing : php-devel-5.4.16-46.amzn2.0.2.x86_64                                                             8/26 

  Installing : php-5.4.16-46.amzn2.0.2.x86_64                                                                   9/26 

  Installing : php-odbc-5.4.16-46.amzn2.0.2.x86_64                                                             10/26 

  Installing : php-pgsql-5.4.16-46.amzn2.0.2.x86_64                                                            11/26 

  Installing : php-mysqlnd-5.4.16-46.amzn2.0.2.x86_64                                                          12/26 

  Installing : php-recode-5.4.16-46.amzn2.0.2.x86_64                                                           13/26 

  Installing : php-mbstring-5.4.16-46.amzn2.0.2.x86_64                                                         14/26 

  Installing : php-fpm-5.4.16-46.amzn2.0.2.x86_64                                                              15/26 

  Installing : php-gd-5.4.16-46.amzn2.0.2.x86_64                                                               16/26 

  Installing : php-intl-5.4.16-46.amzn2.0.2.x86_64                                                             17/26 

  Installing : php-xmlrpc-5.4.16-46.amzn2.0.2.x86_64                                                           18/26 

  Installing : php-embedded-5.4.16-46.amzn2.0.2.x86_64                                                         19/26 

  Installing : php-bcmath-5.4.16-46.amzn2.0.2.x86_64                                                           20/26 

  Installing : php-pspell-5.4.16-46.amzn2.0.2.x86_64                                                           21/26 

  Installing : php-dba-5.4.16-46.amzn2.0.2.x86_64                                                              22/26 

  Installing : php-enchant-5.4.16-46.amzn2.0.2.x86_64                                                          23/26 

  Installing : php-soap-5.4.16-46.amzn2.0.2.x86_64                                                             24/26 

  Installing : php-ldap-5.4.16-46.amzn2.0.2.x86_64                                                             25/26 

  Installing : php-snmp-5.4.16-46.amzn2.0.2.x86_64                                                             26/26 

  Verifying  : 1:php-pear-1.10.7-3.amzn2.0.1.noarch                                                             1/26 

  Verifying  : php-recode-5.4.16-46.amzn2.0.2.x86_64                                                            2/26 

  Verifying  : php-odbc-5.4.16-46.amzn2.0.2.x86_64                                                              3/26 

  Verifying  : php-pdo-5.4.16-46.amzn2.0.2.x86_64                                                               4/26 

  Verifying  : php-mbstring-5.4.16-46.amzn2.0.2.x86_64                                                          5/26 

  Verifying  : php-devel-5.4.16-46.amzn2.0.2.x86_64                                                             6/26 

  Verifying  : php-common-5.4.16-46.amzn2.0.2.x86_64                                                            7/26 

  Verifying  : php-fpm-5.4.16-46.amzn2.0.2.x86_64                                                               8/26 

  Verifying  : php-pecl-memcache-3.0.8-4.amzn2.x86_64                                                           9/26 

  Verifying  : php-gd-5.4.16-46.amzn2.0.2.x86_64                                                               10/26 

  Verifying  : php-pgsql-5.4.16-46.amzn2.0.2.x86_64                                                            11/26 

  Verifying  : php-intl-5.4.16-46.amzn2.0.2.x86_64                                                             12/26 

  Verifying  : php-xmlrpc-5.4.16-46.amzn2.0.2.x86_64                                                           13/26 

  Verifying  : php-embedded-5.4.16-46.amzn2.0.2.x86_64                                                         14/26 

  Verifying  : php-bcmath-5.4.16-46.amzn2.0.2.x86_64                                                           15/26 

  Verifying  : php-pspell-5.4.16-46.amzn2.0.2.x86_64                                                           16/26 

  Verifying  : php-5.4.16-46.amzn2.0.2.x86_64                                                                  17/26 

  Verifying  : php-process-5.4.16-46.amzn2.0.2.x86_64                                                          18/26 

  Verifying  : php-cli-5.4.16-46.amzn2.0.2.x86_64                                                              19/26 

  Verifying  : php-dba-5.4.16-46.amzn2.0.2.x86_64                                                              20/26 

  Verifying  : php-xml-5.4.16-46.amzn2.0.2.x86_64                                                              21/26 

  Verifying  : php-enchant-5.4.16-46.amzn2.0.2.x86_64                                                          22/26 

  Verifying  : php-soap-5.4.16-46.amzn2.0.2.x86_64                                                             23/26 

  Verifying  : php-ldap-5.4.16-46.amzn2.0.2.x86_64                                                             24/26 

  Verifying  : php-mysqlnd-5.4.16-46.amzn2.0.2.x86_64                                                          25/26 

  Verifying  : php-snmp-5.4.16-46.amzn2.0.2.x86_64                                                             26/26 

 

Installed:

  php.x86_64 0:5.4.16-46.amzn2.0.2                          php-bcmath.x86_64 0:5.4.16-46.amzn2.0.2                 

  php-cli.x86_64 0:5.4.16-46.amzn2.0.2                      php-common.x86_64 0:5.4.16-46.amzn2.0.2                 

  php-dba.x86_64 0:5.4.16-46.amzn2.0.2                      php-devel.x86_64 0:5.4.16-46.amzn2.0.2                  

  php-embedded.x86_64 0:5.4.16-46.amzn2.0.2                 php-enchant.x86_64 0:5.4.16-46.amzn2.0.2                

  php-fpm.x86_64 0:5.4.16-46.amzn2.0.2                      php-gd.x86_64 0:5.4.16-46.amzn2.0.2                     

  php-intl.x86_64 0:5.4.16-46.amzn2.0.2                     php-ldap.x86_64 0:5.4.16-46.amzn2.0.2                   

  php-mbstring.x86_64 0:5.4.16-46.amzn2.0.2                 php-mysqlnd.x86_64 0:5.4.16-46.amzn2.0.2                

  php-odbc.x86_64 0:5.4.16-46.amzn2.0.2                     php-pdo.x86_64 0:5.4.16-46.amzn2.0.2                    

  php-pear.noarch 1:1.10.7-3.amzn2.0.1                      php-pecl-memcache.x86_64 0:3.0.8-4.amzn2                

  php-pgsql.x86_64 0:5.4.16-46.amzn2.0.2                    php-process.x86_64 0:5.4.16-46.amzn2.0.2                

  php-pspell.x86_64 0:5.4.16-46.amzn2.0.2                   php-recode.x86_64 0:5.4.16-46.amzn2.0.2                 

  php-snmp.x86_64 0:5.4.16-46.amzn2.0.2                     php-soap.x86_64 0:5.4.16-46.amzn2.0.2                 

  php-xml.x86_64 0:5.4.16-46.amzn2.0.2                      php-xmlrpc.x86_64 0:5.4.16-46.amzn2.0.2                 

Complete!

 

2. 홈디렉터리 생성 

홈디렉터리를 /etc/wonmin_com/php 로 만들어줍니다.

[root@php-fpm ec2-user]# mkdir /var/wonmin_com/php -p

 

3. 사용자 생성

[root@php-fpm ec2-user]# useradd --shell /sbin/nologin --home-dir /var/wonmin_com/php nginx

 

4. 디렉터리 권한 추가

어떤 사용자가 파일을 추가하더라도 홈디렉터리 파일의 그룹 권한이 모두 nginx이도록 수정합니다.

[root@php-fpm php]# chmod g+s /var/wonmin_com/php

 

4. 설정파일 수정

설정파일을 수정합니다......우리는 어려우니까.. 그냥 복붙합시다!

[root@php-fpm php]# vi /etc/php-fpm.d/www.conf
; Start a new pool named 'www'.
[www]

; The address on which to accept FastCGI requests.
; Valid syntaxes are:
;   'ip.add.re.ss:port'    - to listen on a TCP socket to a specific address on
;                            a specific port;
;   'port'                 - to listen on a TCP socket to all addresses on a
;                            specific port;
;   '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = 9000

; Set listen(2) backlog. A value of '-1' means unlimited.
; Default Value: -1
;listen.backlog = -1
 
; List of ipv4 addresses of FastCGI clients which are allowed to connect.
; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
; must be separated by a comma. If this value is left blank, connections will be
; accepted from any ip address.
; Default Value: any
;listen.allowed_clients = 127.0.0.1

; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server. Many
; BSD-derived systems allow connections regardless of permissions. 
; Default Values: user and group are set as the running user
;                 mode is set to 0666
;listen.owner = nobody
;listen.group = nobody
;listen.mode = 0666

; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
;       will be used.
; RPM: apache Choosed to be able to access some dir as httpd
user = nginx
; RPM: Keep a group allowed to write in log dir.
group = nginx

; Choose how the process manager will control the number of child processes.
; Possible Values:
;   static  - a fixed number (pm.max_children) of child processes;
;   dynamic - the number of child processes are set dynamically based on the
;             following directives:
;             pm.max_children      - the maximum number of children that can
;                                    be alive at the same time.
;             pm.start_servers     - the number of children created on startup.
;             pm.min_spare_servers - the minimum number of children in 'idle'
;                                    state (waiting to process). If the number
;                                    of 'idle' processes is less than this
;                                    number then some children will be created.
;             pm.max_spare_servers - the maximum number of children in 'idle'
;                                    state (waiting to process). If the number
;                                    of 'idle' processes is greater than this
;                                    number then some children will be killed.
; Note: This value is mandatory.
pm = dynamic

; The number of child processes to be created when pm is set to 'static' and the
; maximum number of child processes to be created when pm is set to 'dynamic'.
; This value sets the limit on the number of simultaneous requests that will be
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
; CGI.
; Note: Used when pm is set to either 'static' or 'dynamic'
; Note: This value is mandatory.
pm.max_children = 50

; The number of child processes created on startup.
; Note: Used only when pm is set to 'dynamic'
; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
pm.start_servers = 5

; The desired minimum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.min_spare_servers = 5

; The desired maximum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.max_spare_servers = 35
 
; The number of requests each child process should execute before respawning.
; This can be useful to work around memory leaks in 3rd party libraries. For
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
; Default Value: 0
;pm.max_requests = 500

; The URI to view the FPM status page. If this value is not set, no URI will be
; recognized as a status page. By default, the status page shows the following
; information:
;   accepted conn    - the number of request accepted by the pool;
;   pool             - the name of the pool;
;   process manager  - static or dynamic;
;   idle processes   - the number of idle processes;
;   active processes - the number of active processes;
;   total processes  - the number of idle + active processes.
; The values of 'idle processes', 'active processes' and 'total processes' are
; updated each second. The value of 'accepted conn' is updated in real time.
; Example output:
;   accepted conn:   12073
;   pool:             www
;   process manager:  static
;   idle processes:   35
;   active processes: 65
;   total processes:  100
; By default the status page output is formatted as text/plain. Passing either
; 'html' or 'json' as a query string will return the corresponding output
; syntax. Example:
;   http://www.foo.bar/status
;   http://www.foo.bar/status?json
;   http://www.foo.bar/status?html
; Note: The value must start with a leading slash (/). The value can be
;       anything, but it may not be a good idea to use the .php extension or it
;       may conflict with a real PHP file.
; Default Value: not set 
;pm.status_path = /status
 
; The ping URI to call the monitoring page of FPM. If this value is not set, no
; URI will be recognized as a ping page. This could be used to test from outside
; that FPM is alive and responding, or to
; - create a graph of FPM availability (rrd or such);
; - remove a server from a group if it is not responding (load balancing);
; - trigger alerts for the operating team (24/7).
; Note: The value must start with a leading slash (/). The value can be
;       anything, but it may not be a good idea to use the .php extension or it
;       may conflict with a real PHP file.
; Default Value: not set
;ping.path = /ping

; This directive may be used to customize the response of a ping request. The
; response is formatted as text/plain with a 200 response code.
; Default Value: pong
;ping.response = pong
 
; The timeout for serving a single request after which the worker process will
; be killed. This option should be used when the 'max_execution_time' ini option
; does not stop script execution for some reason. A value of '0' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
;request_terminate_timeout = 0
 
; The timeout for serving a single request after which a PHP backtrace will be
; dumped to the 'slowlog' file. A value of '0s' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
;request_slowlog_timeout = 0
 
; The log file for slow requests
; Default Value: not set
; Note: slowlog is mandatory if request_slowlog_timeout is set
slowlog = /var/log/php-fpm/www-slow.log
 
; Set open file descriptor rlimit.
; Default Value: system defined value
;rlimit_files = 1024
 
; Set max core size rlimit.
; Possible Values: 'unlimited' or an integer greater or equal to 0
; Default Value: system defined value
;rlimit_core = 0
 
; Chroot to this directory at the start. This value must be defined as an
; absolute path. When this value is not set, chroot is not used.
; Note: chrooting is a great security feature and should be used whenever 
;       possible. However, all PHP paths will be relative to the chroot
;       (error_log, sessions.save_path, ...).
; Default Value: not set
;chroot = 
 
; Chdir to this directory at the start. This value must be an absolute path.
; Default Value: current directory or / when chroot
;chdir = /var/www
 
; Redirect worker stdout and stderr into main error log. If not set, stdout and
; stderr will be redirected to /dev/null according to FastCGI specs.
; Default Value: no
;catch_workers_output = yes
 
; Limits the extensions of the main script FPM will allow to parse. This can
; prevent configuration mistakes on the web server side. You should only limit
; FPM to .php extensions to prevent malicious users to use other extensions to
; exectute php code.
; Note: set an empty value to allow all extensions.
; Default Value: .php
;security.limit_extensions = .php .php3 .php4 .php5

; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
; the current environment.
; Default Value: clean env
;env[HOSTNAME] = $HOSTNAME
;env[PATH] = /usr/local/bin:/usr/bin:/bin
;env[TMP] = /tmp
;env[TMPDIR] = /tmp
;env[TEMP] = /tmp

; Additional php.ini defines, specific to this pool of workers. These settings
; overwrite the values previously defined in the php.ini. The directives are the
; same as the PHP SAPI:
;   php_value/php_flag             - you can set classic ini defines which can
;                                    be overwritten from PHP call 'ini_set'. 
;   php_admin_value/php_admin_flag - these directives won't be overwritten by
;                                     PHP call 'ini_set'
; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.

; Defining 'extension' will load the corresponding shared extension from
; extension_dir. Defining 'disable_functions' or 'disable_classes' will not
; overwrite previously defined php.ini values, but will append the new value
; instead.

; Default Value: nothing is defined by default except the values in php.ini and
;                specified at startup with the -d argument
;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
;php_flag[display_errors] = off
php_admin_value[error_log] = /var/log/php-fpm/www-error.log
php_admin_flag[log_errors] = on
;php_admin_value[memory_limit] = 128M

; Set session path to a directory owned by process user
php_value[session.save_handler] = files
php_value[session.save_path] = /var/lib/php/session

 

5. index.php파일 생성

[root@php-fpm php]# cat /var/wonmin_com/php/index.php 
<HTML>
  <HEAD>
    <TITLE>php-fpm</TITLE>
  </HEAD>
  <BODY>
        <?php
        echo "Welcome to test";
        phpinfo();
        ?>
  </BODY>
</HTML>

6. php-fpm 서비스 시작 및 enable

[root@php-fpm php]# systemctl enable php-fpm
Created symlink from /etc/systemd/system/multi-user.target.wants/php-fpm.service to /usr/lib/systemd/system/php-fpm.service.
[root@php-fpm php]# systemctl start php-fpm

 

서비스 확인

1. 기본 페이지 확인

index.php가 아닌 기본 페이지입니다.

자! 이제 테스트 페이지를 열어보겠습니다. URL에 서버의 IP를 입력합니다!

 

이제 뒤에 index.php파일 경로를 넣어 정상적으로 로드 되는지 확인합니다.

 

 

^^성공!

728x90