LoginSignup
8

More than 5 years have passed since last update.

CentOS 6.8のopensslを1.0.2にし、nginxをHTTP/2に対応させたい!

Last updated at Posted at 2016-09-19

環境

  • CentOS 6.8
  • openssl 1.0.1(yumからインストール)→openssl 1.0.2
  • nginx 1.11.3(yumからインストール)→nginx 1.11.4(2016/09/20時点最新版)

opensslの設定

cd /usr/local/src
sudo wget https://www.openssl.org/source/openssl-1.0.2-latest.tar.gz
sudo tar -zxf openssl-1.0.2-latest.tar.gz

opensslは以上。

nginxの設定

上記からインストールしたいバージョンを選択。

cd /usr/local/src
sudo wget http://nginx.org/download/nginx-1.11.4.tar.gz
sudo tar -zxf nginx-1.11.4.tar.gz

njsのインストール

nginxのインストールに必要な、njsをインストール。
自分の環境では1.0.1だったので下記設定をしました。(nginx -Vで確認)

cd /usr/local/src
sudo wget http://hg.nginx.org/njs/archive/cdb8d20935ee.tar.gz
sudo tar -zxf cdb8d20935ee.tar.gz

sudo mv ./njs-cdb8d20935ee ./nginx-1.11.4
cd ./nginx-1.11.4
sudo mv njs-cdb8d20935ee njs-0.1.0
cd ./nginx-1.11.4/njs-0.1.0
sudo ./configure

nginxのインストール

nginx -Vでconfigureの設定を確認し、--with-openssl=/usr/local/src/openssl-1.0.2hを追加する(opensslのバージョンは確認してください)

cd ../
sudo ./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_perl_module=dynamic --add-dynamic-module=njs-0.1.0/nginx --with-threads --with-stream --with-stream_ssl_module --with-stream_geoip_module=dynamic --with-http_slice_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_v2_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' --with-openssl=/usr/local/src/openssl-1.0.2h
sudo make
sudo make install

nginxのリスタート

sudo service restart nginx
nginx -v

上記で1.11.4に切り替わっているか確認。

.confファイルの設定

あとはnginxの設定(nginx.confやsites-available/*.conf)に、

listen 443 ssl http2;

http2を追加してあげれば無事HTTP/2でサーバーが動作します。
_tanshio_2016-9月-20.jpg
快適HTTP/2ライフを!

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8