Skip to content

Instantly share code, notes, and snippets.

@concatime
Last active December 3, 2018 06:04
Show Gist options
  • Save concatime/6c79f33ca1a2846698e4dd9c46a92e69 to your computer and use it in GitHub Desktop.
Save concatime/6c79f33ca1a2846698e4dd9c46a92e69 to your computer and use it in GitHub Desktop.

H2Ø WIZARD

Features of h2o_wizard:

  • Bleading Edge ;
  • Compiled from scratch;
  • Based on static libraries ;
  • LibreSSL as SSL library ;

This script is provided AS IS & comes with ABSOLUTELY NO WARRANTY!

Instructions

You need to install a c compiler, ninja, cmake, make, automake and libtool. Then, run this command:

bash <(curl -s https://gist.githubusercontent.com/concatime/6c79f33ca1a2846698e4dd9c46a92e69/raw/.bash)

And…, that’s it!

Well, if you want to use a custom version of clang, you can give an argument to the command, e.g. 4.0.

On Ubuntu 16.04.2 (WSL), run:

sudo apt install clang-4.0 ninja-build make cmake automake libtool --yes --no-install-recommends

and you should give 4.0 as an argument to the main command.

To install dependencies on Fedora 26 (where curl, unzip, make & pkg-config are preinstalled), run:

dnf check-update || sudo dnf upgrade-minimal --assumeyes
sudo dnf install -by git-core clang cmake ninja-build libtool python-sphinx-doc --setopt=install_weak_deps=False
sudo dnf clean all

Source.

Test-It!

sudo systemctl start h2o
curl 127.0.0.1:8080

Optional

adduser --system --ingroup www-data --disabled-login --disabled-password --no-create-home --home /nonexistent --quiet h2o

Sources: #1 & #2.

Warnings

H2O

WSLAY

To-Do

  • Mute output
  • Resolve privileges’ errors (sudo)
  • Make it bulletproof against error-prone (set -e)

Random links

mozumder here and here.

H2O=2.2.4
LIBUV=1.18.0
WSLAY=1.0.0
export CFLAGS=-pipe
set -e
# autoreconf sphinx-build pkg-config
# The script will stop if anyone not found because of the previous line
for k in ln cd mkdir mktemp pushd popd echo wait sudo curl wget git cc c++ ninja cmake make automake autoconf aclocal libtoolize install
do hash $k 1>&-
done
echo 'All dependencies are met!'
# Function to clone a github repo
clone() {
local link=$1 rel=$2
git clone https://github.com/$link.git --branch ${rel:-master} --config advice.detachedHead=false --quiet &
}
# ~~Too buzzy~~ (or lazy) Not anymore ;)
# By running the one line command, it meens that you got curl
#sudo printf 'You should have git, c/make, automake, libtool and a c/c++ compiler installed BEFORE running this script!\nWait 5 seconds to continue, otherwise hit CNTRL’C to abort\n'
#sleep 5
#git config --global advice.detachedHead false
pushd $(mktemp --directory)
clone tatsuhiro-t/wslay
for k in libressl libuv zlib
do sh <(curl -s https://gist.githubusercontent.com/concatime/d0e95351b889a7c709af2cd3e3adb908/raw/$k.sh)
done
wait
clone h2o/h2o v$H2O
pushd wslay
mkdir build-ninja
cd build-ninja
cmake .. -G Ninja \
-DCMAKE_BUILD_TYPE=Release
sudo ninja install
rm `pwd` --recursive --force
popd
wait
sudo ldconfig
pushd h2o
mkdir build-ninja
cd build-ninja
cmake .. -G Ninja \
-DWITH_MRUBY=off \
-DLIBUV_VERSION=$LIBUV \
-DCMAKE_BUILD_TYPE=Release
sudo ninja install
popd
rm `pwd` --recursive --force
popd
pushd /usr/local/etc
sudo curl https://gist.githubusercontent.com/concatime/6c79f33ca1a2846698e4dd9c46a92e69/raw/h2o.conf --silent --remote-name
popd
pushd /lib/systemd/system
sudo curl https://gist.githubusercontent.com/concatime/6c79f33ca1a2846698e4dd9c46a92e69/raw/h2o.service --silent --remote-name
popd
echo ' # systemctl [re/start, reload, stop, enable] h2o'
echo …done
#user: h2o
pid-file: /run/h2o.pid
access-log: share/h2o/access.log
error-log: share/h2o/error.log
hosts:
'127.0.0.1':
listen:
port: 8080
paths:
'/':
file.dir: share/doc/h2o
[Unit]
Description=H2Ø ~ Optimized HTTP server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/run/h2o.pid
WorkingDirectory=/usr/local
ExecStart=/usr/local/bin/h2o --mode daemon
ExecStartPost=/bin/sleep .01
ExecReload=/bin/kill -HUP $MAINPID
ExecStop=/bin/kill -TERM $MAINPID
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment