Alpine — Add a Web Server

How to add a Web Server to a regular Linux virtual machine. A minimal Alpine VM is a good base for services like Nginx as a web server. Alpine ensures minimal VM overhead.

Alpine — Add a Web Server
Photo by Lee Roylland / Unsplash

This is a short post of adding a Nginx web server to an Alpine VM.

Install

doas apk update && doas apk add nginx

Add a user

doas adduser -D -g 'www' www

Create a directory for HTML -files

doas mkdir /www
doas chown -R www:www /var/lib/nginx
doas chown -R www:www /www

Configuring NginX to listen to port 80

doas nano /etc/nginx/nginx.conf

Start Nginx

After the installation, NginX is not running. To start NginX, use start.

doas rc-service nginx start

Adding the community repo

If you need things like the Qemu-Guest-Agent or sudo, you need to activate the community repo. Edit the file /etc/apk/repositories and remove the # in front of the …/community lines.