H2O

the optimized HTTP/1.x, HTTP/2, HTTP/3 server

Powered by Oktavia

Configure > Quick Start

In order to run the H2O standalone HTTP server, you need to write a configuration file. The minimal configuration file looks like as follows.

hosts:
  "myhost.example.com":
    listen:
      port: 80
    listen:
      port: 443
      ssl: {}
    listen:
     port: 443
      ssl: {}
      type: quic
    paths:
      /:
        file.dir: /path/to/the/public-files

user: nobody
access-log: /path/to/the/access-log
error-log: /path/to/the/error-log
pid-file: /path/to/the/pid-file

acme:
  email: admin@myhost.example.com
  accept-tos: YES

The configuration instructs the server to:

  1. serve contents under the hostname: myhost.example.com
  2. for HTTP, listen on TCP port 80
  3. for HTTPS, listen on TCP port 443 and UDP port 443
  4. serve files under /path/to/the/public-files
  5. run under the privileges of nobody
  6. emit access logs to file: /path/to/the/access-log
  7. emit error logs to /path/to/the/error-log
  8. store the process id of the server in /path/to/the/pid-file
  9. use ACME to fetch the TLS certificates automatically (note: lego must be installed for this to work).

Enter the command below to start the server.

% sudo h2o -m daemon -c /path/to/the/configuration-file

The command instructs the server to read the configuration file, and start in daemon mode, which dispatches a pair of master and worker processes that serves the HTTP requests.

To stop the server, send SIGTERM to the server.

% sudo kill -TERM `cat /path/to/the/pid-file`

Next Step

Now that you know how to start and stop the server, the next step is to learn the configuration directives and their structure, or see the configuration examples.