Setup httpd on OpenBSD

Rob V

This article shows how to set up a web server on OpenBSD. The web server we will use is OpenBSD built in httpd.

Log into the OpenBSD machine over SSH and change to root user by typing su.

Copy the httpd.conf example file to the /etc directory with the following command:

cp /etc/examples/httpd.conf /etc/httpd.conf

Now lets edit /etc/httpd.conf

vi /etc/httpd.conf

I have removed most lines in the file leaving only what can be seen here.

# $OpenBSD: httpd.conf,v 1.14 2015/02/04 08:39:35 florian Exp $

# Macros

# A name-based "virtual" server on the same address
server "" {
        listen on $ext_addr port 80
        root "/htdocs/"

# Include MIME types instead of the built-in ones
types {
        include "/usr/share/misc/mime.types"

Note, here we are using the domain This will need to be changed to your domain.

I am using a virtual server because I may at a later date add more domains.

Let’s create the directory to serve our website from:

mkdir -p /var/www/htdocs/

Now create a test file:

echo '<h1>Hello World!</h1>' > /var/www/htdocs/

Start httpd with the following command:

rcctl start httpd

Set httpd to start at boot:

rcctl enable httpd

Now try pointing your browser to our domain, we should see our web page.

Ensure your domain points to your server by setting up the appropriate DNS records with your domain name provider.

That’s it



comments powered by Disqus