OpenBSD Web Server - Beginner Guide
OpenBSD Web Server - Beginner Guide
OpenBSD comes with a built-in web server called httpd. Here's how to set it up for beginners.
Step 1: Install the Web Server
OpenBSD uses the pkg_add command to install software.
pkg_add apache24 - installs Apache 2.4
pkg_add nginx - installs nginx (popular alternative)
pkg_add httpd - installs OpenBSD's own httpd (simplest for beginners)
Step 2: Start the Web Server
After installing, start the service:
rcctl enable apache24 - starts Apache on boot
rcctl start apache24 - starts Apache immediately
rcctl status apache24 - check if it's running
Test it: Open your web browser and go to: http://localhost
You should see: "OpenBSD httpd default page
Step 3: Place Your Website Files
By default, Apache/httpd looks for files in:
/var/www/htdocs
Create your first page:
echo "Hello OpenBSD!" > /var/www/htdocs/index.html
Or use a text editor:
vi /var/www/htdocs/index.html
Press i to insert text, type your message, press Esc, then type :wq and press Enter to save
Step 4: Configure for Your Network
By default, httpd listens on port 80 (HTTP) and optionally 443 (HTTPS).
To change the port:
vi /etc/apache2/httpd.conf
Find the line with Listen 80 and change to your preferred port
Important: If you change the port, you must also allow it through the firewall:
pfctl -e (if not already enabled)
pfctl -f /etc/pf.conf
# Allow HTTP
pass in on egress proto tcp from any to any port 80
# Allow HTTPS
pass in on egress proto tcp from any to any port 443
Step 5: Test from Another Computer
Find your OpenBSD's IP address:
ifconfig - shows IP address (look for inet)
From another computer on the same network, go to:
http://192.168.1.100 (replace with your IP)
First time: You may see a security warning - this is normal!
Click "Advanced" then "Proceed" to see your page.
Want to set up PHP with your web server? Proceed to Lesson 17: Install PHP.
Next: OpenBSD PostgreSQL Database - Beginner Guide
Article author: Arthur Isaev