DEV Community

loading...
Cover image for How to run a webserver with httpd on OpenBSD 6.3

How to run a webserver with httpd on OpenBSD 6.3

mnlwldr profile image manuel Originally published at wildauer.io on ・1 min read

Populate /etc/httpd.conf and replace example.com with your domain

server "example.com" {
  listen on * port 80
  root "/htdocs/example.com"
}

The httpd daemon is chrooted to /var/www by default so root "/htdocs/example.com" means /var/www/htdocs/exmaple.com.

We should create our document root

mkdir -p /var/www/htdocs/example.com

add a index.html file with a placeholder to the new directory

echo "Hello World from OpenBSD 6.3">/var/www/htdocs/example.com/index.html

Check httpd configuration

httpd -n

When everythings looks ok, enable and start httpd

rcctl enable httpd
rcctl start httpd

Now you should reach your website with your IP address.

Discussion (0)

pic
Editor guide