LoginSignup
11
8

More than 5 years have passed since last update.

ISUCONで話題になったWebサーバー、h2oをUbuntu 18.04で動かしてみる

Last updated at Posted at 2018-09-18

はじめに

この文書は怪文書です。

  • Ubuntu 18.04で
  • できるだけ労力を少なく
  • h2oを動かしてみる

をやってみようと思います。

CentOSの場合はRPMが、Dockerの場合はDocker Hubにイメージがあるのでそれを使ってあげるとよさそうです。

事前準備

  1. Ubuntu 18.04のマシンを用意する

以上。

インストールをやってみる

これを実行するだけです。

install_h2o.sh
#!/bin/bash
## apt update && apt upgrade -y && apt autoremove -y
## やろうとしたらlockファイルがあって死んだのでlockファイルを消した
## rm -rf /var/lib/dpkg/lock
apt update && apt upgrade -y && apt autoremove -y
apt -y install locate git cmake build-essential checkinstall autoconf pkg-config libtool python-sphinx wget libcunit1-dev nettle-dev libyaml-dev libuv-dev libssl-dev zlib1g-dev
git clone https://github.com/tatsuhiro-t/wslay.git
git clone https://github.com/h2o/h2o.git
cd wslay/
autoreconf -i
automake
autoconf
./configure
make
make install
cd ../h2o/
cmake -DWITH_BUNDLED_SSL=on .
make
make install

Systemdに突っ込んでみる

3年前の記事ですがこれが使えます。

/lib/systemd/system/h2o.service
[Unit]
Description=H2O the optimized HTTP/1, HTTP/2 server
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/var/run/h2o/h2o.pid
ExecStartPre=/usr/local/bin/h2o -c /etc/h2o/h2o.conf -t
ExecStart=/usr/local/bin/h2o -c /etc/h2o/h2o.conf -m daemon
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target
/etc/h2o/h2o.conf
user: nobody
hosts:
#  "www.example.com:443":
#    listen:
#      port: 443
#      host: 0.0.0.0
# Let's Encryptを入れる場合
#      ssl:
#        certificate-file: "/etc/letsencrypt/live/www.example.com/fullchain.pem"
#        key-file: "/etc/letsencrypt/live/www.example.com/privkey.pem"
#    paths:
#      "/":
#        file.dir: /var/www/html
  "www.example.com:80":
    listen:
      port: 80
      host: 0.0.0.0
    paths:
      "/":
        file.dir: /var/www/html
access-log: /var/log/h2o/access.log
error-log: /var/log/h2o/error.log
pid-file: /var/run/h2o/h2o.pid

コンフィグを突っ込んだら以下のコマンドを叩きます

systemctl enable h2o.service
systemctl start h2o
11
8
0

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
11
8