Running your own service in Tor under a Debian based operating system is easy:

  1. Install tor: sudo apt-get install tor

  2. You’ll need a webserver already. I assume, you are running apache.

  3. Configure your onion service in /etc/tor/torrc:

     HiddenServiceDir /var/lib/tor/hidden_service_myname/
     HiddenServicePort 80 127.0.0.1:80
    

    Replace myname with your choice. Any request on port 80 on your hidden service will then be redirected to port 80 on localhost - that’s where your apache webserver is running.

  4. Restart tor service: sudo systemctl restart tor.service

  5. Check out your hostname of the hidden service: sudo cat /var/lib/tor/hidden_service_myname/hostname. You’ll see a hostname ending in “.onion”. Remember this - this is your onion hostname.

  6. Configure your webserver, add a name-based virtual host:

     <VirtualHost *:80>
         ServerName xyzyourhiddenservicehostnamexyz.onion
    
         DocumentRoot /srv/www/myname/htdocs
     </VirtualHost>
    
  7. Restart your webserver

  8. Try it out with the tor browser.

That way, I made this homepage also available as t2irhp5ym2ioy7jivr7oomg2gt2y3mbmtshenveh7eymp7ho3l3hvhyd.onion.

One note: the hostname depends on the generated public/private key pair that tor generated for your onion service. These keys are available in the “HiddenServiceDir” (e.g. /var/lib/tor/hidden_service_myname/). If you want to keep your address, you better make sure, to backup this directory.

More detailed information can be found on Configuring Onion Services for Tor.