HTTP/2 TLSv3 な Nginx をインストール(Ubuntu16.04/18.04)

nginx-build を使うことでトラブル無くビルド・管理が出来ます。
凄くオススメです。

Ubuntu 16.04に Go を入れる

sudo apt update
sudo apt upgrade -y
cd /tmp
wget https://dl.google.com/go/go1.11.linux-amd64.tar.gz
sudo tar -xvf go1.11.linux-amd64.tar.gz
sudo mv go /usr/local
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
go version

nginx-build の導入

go get -u github.com/cubicdaiya/nginx-build
nginx-build -version

Nginx のビルド
オプションを記述したシェルを用意して、ビルドします。

sudo mkdir work
sudo chown usrname:usrname -R work
nginx-build -d work -c ./install.sh -clear

Nginx のインストール

cd work/nginx/1.17.9/nginx-1.17.9
sudo service nginx stop
sudo make install
sudo service nginx start
nginx -V

シェル
前述のシェルはこのような感じで記述しておきます。
./install.sh

#!/bin/sh
./configure \
--prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--modules-path=/usr/lib/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-openssl=/usr/local/src/openssl-1.1.1d \
--with-openssl-opt=enable-tls1_3 \
--with-compat \
--with-file-aio \
--with-threads \
--with-pcre \
--with-pcre-jit \
--with-http_addition_module \
--with-http_auth_request_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_mp4_module \
--with-http_random_index_module \
--with-http_realip_module \
--with-http_secure_link_module \
--with-http_slice_module \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_sub_module \
--with-http_v2_module \
--with-mail \
--with-mail_ssl_module \
--with-stream \
--with-stream_realip_module \
--with-stream_ssl_module \
--with-stream_ssl_preread_module \
--with-cc-opt='-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC'  --with-ld-opt='-Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie' #

参考
今日からGoをはじめる人に伝えたい$GOPATHではまった話
Ubuntu 16.04に golang 1.11 をインストールする
nginx-buildでnginxをビルドしよう

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください