Install Tor.
apt install tor
Edit /etc/tor/torrc to allow connections to and from the hidden service.
nano -$ /etc/tor/torrc
Go to the lines that say:
#HiddenServiceDir /var/lib/tor/hidden_service/
#HiddenServicePort 80 127.0.0.1:80
Uncomment them by deleting the # mark in front of each line.
If you want, you can change the HiddenServiceDir directory, but you will need to remember it for later. (You will need to do this if you want multiple Tor hidden services.) For security purposes, keep the new directory inside of /var/lib/tor/.
Save and exit the text editor, then restart the Tor process.
systemctl restart tor@default
Now get the address of your new service. (If you picked a different HiddenServiceDir, now is the time to remember it.)
cat /var/lib/tor/hidden_service/hostname
Whatever comes up is your address for when you set up your web server.
Source - https://letsdecentralize.org/setup.html