Skip to content

Instantly share code, notes, and snippets.

@ryu1
Created November 27, 2017 17:29
Show Gist options
  • Select an option

  • Save ryu1/df1d38decbe257f5e1994bd3b9937bad to your computer and use it in GitHub Desktop.

Select an option

Save ryu1/df1d38decbe257f5e1994bd3b9937bad to your computer and use it in GitHub Desktop.

How To Install Nginx v1.6.2

Description:

  1. Nginxのリポジトリを登録する

     # rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
     
  2. インストールされるNginxのバージョンを確認する

     [root@Meiden001stg ~]# yum info nginx
     Loaded plugins: amazon-id, product-id, rhui-lb, security, subscription-manager
     Updating certificate-based repositories.
     Unable to read consumer identity
     Repository 'epel-erlang' is missing name in configuration, using id
     Repository 'epel-erlang-source' is missing name in configuration, using id
     nginx                                                                                                  | 2.9 kB     00:00
     nginx/primary_db                                                                                       |  33 kB     00:00
     Available Packages
     Name        : nginx
     Arch        : x86_64
     Version     : 1.6.2
     Release     : 1.el6.ngx
     Size        : 336 k
     Repo        : nginx
     Summary     : High performance web server
     URL         : http://nginx.org/
     License     : 2-clause BSD-like license
     Description : nginx [engine x] is an HTTP and reverse proxy server, as well as
                 : a mail proxy server.
     
  3. Nginxをインストールする

     [root@Meiden001stg ~]# yum install nginx
     Loaded plugins: amazon-id, product-id, rhui-lb, security, subscription-manager
     Updating certificate-based repositories.
     Unable to read consumer identity
     Repository 'epel-erlang' is missing name in configuration, using id
     Repository 'epel-erlang-source' is missing name in configuration, using id
     Setting up Install Process
     Resolving Dependencies
     --> Running transaction check
     ---> Package nginx.x86_64 0:1.6.2-1.el6.ngx will be installed
     --> Processing Dependency: openssl >= 1.0.1 for package: nginx-1.6.2-1.el6.ngx.x86_64
     --> Processing Dependency: libssl.so.10(libssl.so.10)(64bit) for package: nginx-1.6.2-1.el6.ngx.x86_64
     --> Processing Dependency: libcrypto.so.10(libcrypto.so.10)(64bit) for package: nginx-1.6.2-1.el6.ngx.x86_64
     --> Processing Dependency: libcrypto.so.10(OPENSSL_1.0.1_EC)(64bit) for package: nginx-1.6.2-1.el6.ngx.x86_64
     --> Running transaction check
     ---> Package openssl.x86_64 0:1.0.0-27.el6_4.2 will be updated
     --> Processing Dependency: openssl = 1.0.0-27.el6_4.2 for package: openssl-devel-1.0.0-27.el6_4.2.x86_64
     ---> Package openssl.x86_64 0:1.0.1e-30.el6 will be an update
     --> Running transaction check
     ---> Package openssl-devel.x86_64 0:1.0.0-27.el6_4.2 will be updated
     ---> Package openssl-devel.x86_64 0:1.0.1e-30.el6 will be an update
     --> Finished Dependency Resolution
     
     Dependencies Resolved
     
     ==============================================================================================================================
      Package                 Arch             Version                    Repository                                          Size
     ==============================================================================================================================
     Installing:
      nginx                   x86_64           1.6.2-1.el6.ngx            nginx                                              336 k
     Updating for dependencies:
      openssl                 x86_64           1.0.1e-30.el6              rhui-ap-northeast-1-rhel-server-releases           1.5 M
      openssl-devel           x86_64           1.0.1e-30.el6              rhui-ap-northeast-1-rhel-server-releases           1.2 M
     
     Transaction Summary
     ==============================================================================================================================
     Install       1 Package(s)
     Upgrade       2 Package(s)
     
     Total download size: 3.0 M
     Is this ok [y/N]: y
     Downloading Packages:
     (1/3): nginx-1.6.2-1.el6.ngx.x86_64.rpm                                                                | 336 kB     00:00
     (2/3): openssl-1.0.1e-30.el6.x86_64.rpm                                                                | 1.5 MB     00:00
     (3/3): openssl-devel-1.0.1e-30.el6.x86_64.rpm                                                          | 1.2 MB     00:00
     ------------------------------------------------------------------------------------------------------------------------------
     Total                                                                                         1.9 MB/s | 3.0 MB     00:01
     Running rpm_check_debug
     Running Transaction Test
     Transaction Test Succeeded
     Running Transaction
     Warning: RPMDB altered outside of yum.
       Updating   : openssl-1.0.1e-30.el6.x86_64                                                                               1/5
       Installing : nginx-1.6.2-1.el6.ngx.x86_64                                                                               2/5
     ----------------------------------------------------------------------
     
     Thanks for using nginx!
     
     Please find the official documentation for nginx here:
     * http://nginx.org/en/docs/
     
     Commercial subscriptions for nginx are available on:
     * http://nginx.com/products/
     
     ----------------------------------------------------------------------
       Updating   : openssl-devel-1.0.1e-30.el6.x86_64                                                                         3/5
       Cleanup    : openssl-devel-1.0.0-27.el6_4.2.x86_64                                                                      4/5
       Cleanup    : openssl-1.0.0-27.el6_4.2.x86_64                                                                            5/5
     Installed products updated.
       Verifying  : nginx-1.6.2-1.el6.ngx.x86_64                                                                               1/5
       Verifying  : openssl-devel-1.0.1e-30.el6.x86_64                                                                         2/5
       Verifying  : openssl-1.0.1e-30.el6.x86_64                                                                               3/5
       Verifying  : openssl-devel-1.0.0-27.el6_4.2.x86_64                                                                      4/5
       Verifying  : openssl-1.0.0-27.el6_4.2.x86_64                                                                            5/5
     
     Installed:
       nginx.x86_64 0:1.6.2-1.el6.ngx
     
     Dependency Updated:
       openssl.x86_64 0:1.0.1e-30.el6                             openssl-devel.x86_64 0:1.0.1e-30.el6
     
     Complete!
     
  4. Nginxのconfを設定する

     server {
         listen       80;
         server_name  localhost;
         # Tomcat
         location /xxx {
             proxy_pass         http://localhost:8080/xxx/;
             proxy_cookie_path  /xxx/ /xxx/;
             proxy_set_header   X-Forwarded-For $remote_addr;
         }
         # Node.js
         location /yyy {
             proxy_pass         http://localhost:9000/yyy/;
             proxy_cookie_path  /yyy/ /yyy/;
             proxy_set_header   X-Forwarded-For $remote_addr;
         }
     }
     # SSLはELB?不要?
     server {
         listen       443 ssl;
         server_name  localhost;
     
         ssl_certificate      /etc/nginx/cert.pem;
         ssl_certificate_key  /etc/nginx/cert.key;
     
         ssl_session_cache shared:SSL:1m;
         ssl_session_timeout  5m;
     
         ssl_ciphers  HIGH:!aNULL:!MD5;
         ssl_prefer_server_ciphers   on;
     
         location /xxx {
             proxy_pass         http://localhost:8080/xxx/;
             proxy_cookie_path  /xxx/ /xxx/;
             proxy_set_header   X-Forwarded-For $remote_addr;
         }
    
         location /yyy {
             proxy_pass         http://localhost/yyy/;
             proxy_cookie_path  /yyy/ /yyy/;
             proxy_set_header   X-Forwarded-For $remote_addr;
         }
     }
     
  5. Nginxを起動する

     # service nginx start
     
  6. Nginxのサービスが自動起動するよう設定する

     # chkconfig nginx on
     
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment