Tor: How do I host an onion service?

Run a local web service, install and configure Tor, and map an onion service port to the local service as shown in the Tor Project's setup guide.

Short answer

Run a local web service, install and configure Tor, and map an onion service port to the local service as shown in the Tor Project's setup guide. Tor creates a .onion address and private key in the service directory. Test from Tor Browser, protect the key, and harden the web application itself; onion routing does not repair application vulnerabilities.

Sources

Tor Project: Set up an onion service.