How to Host V3 .Onion Website With Custom Domain on Linux

Linux TLDR
Last Updated:
Reading time: 7 minutes

This article shows you how to set up .onion website with a custom domain for localhost on the dark web. Why would someone want to host their website on the dark web? The reasons could be anything from hosting a private site and keeping othersโ€™ eyes away from it to showcasing a site to friends to demonstrate its coolness.

The dark web websiteโ€™s web address ends with .onion followed by random strings of letters and numbers, though they actually represent the public key generated when the user created their hidden service.

To access your website, you need a specialized web browser, and Tor Browser is currently the most popular browser for accessing onion websites. Weโ€™ve already written an article on Tor installation, so you can follow that and install it on your Linux system.

Without wasting any further time, letโ€™s see how one can easily host a V3 .onion website with a custom domain on Linux.

Tutorial Details

DescriptionHost Localhost on DarkWeb with Custom Web Address
Difficulty LevelModerate
Root or Sudo PrivilegesYes
OS CompatibilityUbuntu, Manjaro, Fedora, etc.
Internet RequiredYes

How to Host V3 .Onion Website With Custom Domain on Linux

To show you how to host an .onion website on the dark web, you must first need a webserver; this server acts as the backend, so when you set up an onion service and someone accesses your site, they will reach your local web server through the onion network.

Iโ€™ve included a list of widely used webservers below.

Web ServerComes PreinstalledWhen to use
Apache2 (recommended)Ubuntu, RedHat, Fedora, OpenSUSE, etc.Itโ€™s overall good and the most popular, so you can start using it directly.
NginxManual installation is required.If you need parallel processing and a fast webserver, then opt for this.
Python HTTP ServerManual installation is required.Itโ€™s only good for testing purposes.

In this tutorial, Iโ€™ll use Apache2 as a webserver for my onion website and later configure it with the Tor network and a custom domain. So, letโ€™s start with setting Apache2โ€ฆ

How to Install Apache2 on Linux

Apache2 is a popular web server that comes pre-installed in most Linux distributions, but in some distributions where itโ€™s not installed, you can use one of the following commands to install it:

# On Debian, Ubuntu, Mint, Pop!_OS, etc.
$ sudo apt install apache2

# On RedHat, Fedora, AlmaLinux, etc.
$ sudo dnf install httpd

Once done, you must enable the Apache2 service to auto-start on every system boot; for this purpose, you can use the following systemctl command:

# On Debian, Ubuntu, Mint, Pop!_OS, etc.
$ sudo systemctl enable apache2

# On RedHat, Fedora, AlmaLinux, etc.
$ sudo systemctl enable httpd.service

The Apache2 installation task is complete; now, โ€œ/var/www/htmlโ€ will serve as the document root directory for Apache2 (where all files accessible via the webserver are stored).

I suggest you remove all the content from the document root directory and then create a new โ€œindex.htmlโ€ file using the following commands:

$ sudo rm -r /var/www/html/*
$ sudo touch /var/www/html/index.html

Once done, edit the โ€œ/var/www/html/index.htmlโ€ using your choice of text editor; if you ask for my recommendation, I suggest using either Vim or Nano commands to edit it.

$ sudo nano /var/www/html/index.html


$ sudo vim /var/www/html/index.html

Once you open the file, copy and paste the following HTML template.

<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Linux TLDR</title>
    <h1 style="text-align: center;">Welcome to Linux TLDR</h1>
    <p style="text-align: center; font-style: italic;">Welcome to <a href="">Linux TLDR</a>, your go-to for guides, troubleshooting, and the latest updates on Linux distributions.</p>

Once youโ€™ve finished editing, save the file. If youโ€™re using Nano Editor, press โ€œCtrl+Oโ€œ, hit โ€œEnterโ€œ, and then โ€œCtrl+Xโ€œ. If youโ€™re using the Vim editor, enter in command-line mode and then type and enter the โ€œ!wqโ€ command.

Just to confirm that all configurations are correct, restart your web server.

# On Debian, Ubuntu, Mint, Pop!_OS, etc.
$ sudo systemctl reload apache2

# On RedHat, Fedora, AlmaLinux, etc.
$ sudo systemctl reload httpd.service

Finally, you can open your favorite browser, either Chrome or Firefox, and access your web server from the following web address:



accessing localhost site on firefox

If youโ€™re unable to access the web server, try the following solution:

  • Make sure you are accessing localhost without https; the web address must be โ€œhttp://localhostโ€œ.
  • Restart the Apache2 service using the โ€œsudo systemctl reload apache2 or httpd.serviceโ€ command.
  • Check if any existing process is using port 80 (which is used by Apache2) using โ€œsudo ss -tulpn | grep :80โ€œ. If it is found, then stop the process responsible for using that port.

The above solution will fix the issues, but if the problem still persists, then you can ask for our assistance in the comment section. So, now letโ€™s see how you can setup Torโ€ฆ

How to Setup and Host Onion Website on Linux

To host an onion website on your Linux system, you need to install the Tor package from your default package manager. Below, Iโ€™ve provided the commands for installing Tor on some popular Linux distributions, so you can open the terminal and execute them to start the installation.

# On Debian, Ubuntu, Mint, Pop!_OS, etc.
$ sudo apt install tor

# On RedHat, Fedora, AlmaLinux, etc.
$ sudo dnf install tor

# On Linux or macOS
$ brew install tor

Once the installation is complete, open the Tor config file (named โ€œtorrcโ€œ) using the following command:

$ sudo nano /etc/tor/torrc


$ sudo vim /etc/tor/torrc

Once the file is open, you can either locate the following lines and uncomment them (basically remove โ€œ#โ€ before them) or, to avoid a headache, simply copy-paste them at the end of the file if youโ€™ve never edited a โ€œtorrcโ€ file before to avoid repetition.

HiddenServiceDir /var/lib/tor/hidden_service/
HiddenServicePort 80

After editing, save and close the file, then restart the Tor service to apply the changes.

$ sudo systemctl restart tor

Then execute the following command to get your onion address, and you can simply copy-paste it in the Tor browser address bar:

$ sudo cat /var/lib/tor/hidden_service/hostname


accessing localhost on tor browser

If the Tor browser is unable to access the localhost, you can use the following solution:

  • Make sure you correctly copied the onion address from the โ€œhostnameโ€ file.
  • Restart the Apache2 service using the โ€œsudo systemctl reload apache2 or httpd.serviceโ€ command and the Tor service using the โ€œsudo systemctl restart torโ€ command.

The above solution will fix the issues, but if for any reason it is not able to work in your case, then do let us know in the comment section.

How to Get Custom Domain for V3 Onion Website on Linux

Until now, you have successfully started an Apache2 web server on your Linux system and served the localhost to a Tor network with a random onion web address.ย 

However, if you have seen popular onion web addresses for Facebook, GitHub, or Reddit, you might have noticed that their brand initials are first mentioned in their onion web addresses; for Facebook, it would be โ€œfacebookwkhpilnemx***.onionโ€œ.

While having only a few brand initials mixed with random letters and numbers may not help users remember the URL address, itโ€™s a good way to provide them with a sense of reassurance that theyโ€™re accessing a genuine site. And for that purpose, Iโ€™ll show you how to add your brandโ€™s initials to your onion web address.

You can generate a V2 .onion address with โ€œeschallotโ€œ, but itโ€™s not recommended. For that reason, Iโ€™ll show you how to generate a V3 .onion address using โ€œed25519โ€ with the โ€œmkp224oโ€ tool.

First, open your terminal and install some necessary dependencies using the following command:

# On Debian, Ubuntu, Mint, Pop!_OS, etc.
$ apt install gcc libsodium-dev make autoconf

# On RedHat, Fedora, AlmaLinux, etc.
$ sudo dnf install libsodium-devel
$ sudo dnf groupinstall "Development Tools"

Once finished, clone the mkp224o tool, execute the โ€œautogenโ€ and โ€œconfigureโ€ files, and proceed to compile and install it on your Linux system by running the โ€œmakeโ€ command:

$ git clone
$ cd mkp224o/
$ ./ 
$ ./configure 
$ make

Then you can use the following command to generate your first custom .onion web address with the first four initials โ€œjakeโ€œ.

โš ๏ธ
The number of characters used as initials will define the amount of time it takes to generate them, so for the beginning, I would keep it short, between 2 and 5 characters only.
$ ./mkp224o jake -t 4 -v -n 4 -d custom_hostname


creating custom domain for onion network

The following is a breakdown of all the options used to generate the custom .onion web address:

  • โ€œjakeโ€œ: The command will check for this initial to generate the web address.
  • โ€œ-t 4โ€œ: This specifies the number of threads to use, with a larger number resulting in faster execution but requiring more processing power.
  • โ€œ-vโ€œ: Enable verbose (which means every detail will be shown on screen).
  • โ€œ-n 4โ€œ: Generate four suggestions.
  • โ€œ-d custom_hostnameโ€œ: Write the generated hostname and keymatter to the โ€œcustom_hostnameโ€ directory in the present working directory.

Once the onion web address generation task is complete, all necessary files will be saved to the โ€œcustom_hostnameโ€ directory. So, when you list the contents of this directory, youโ€™ll find multiple folders named after the onion address youโ€™ve just generated. Simply enter any one folder to access all the necessary files needed to set up your custom onion address.

$ cd custom_hostname/
$ ls
$ cd <your_desired_onion_directory>
$ ls


checking the content of generated onion address directory

Copy all the content of this directory to your Tor server โ€œ/var/lib/tor/hidden_serviceโ€ directory using the following command:

$ sudo cp * /var/lib/tor/hidden_service


copying the file of generated onion address to hidden_service directory

Restart your Tor service to apply all the changes:

$ sudo systemctl restart tor

You can now copy your chosen custom .onion web address from the directory or simply check the Tor โ€œhostnameโ€ file and paste it into the Tor browser address bar.

$ sudo cat /var/lib/tor/hidden_service/hostname


accessing the my custom onion address on tor browser

Thatโ€™s it. You have finally got your first custom V3 .onion web address on the Tor network.

Final Word

I hope you find this article useful. I know itโ€™s a little complex to do, but if youโ€™re interested in this topic, youโ€™ll find it exciting to have your own custom .onion address.

When accessing your onion site, you might encounter a delay, which is quite common due to its nature. You canโ€™t do anything about it, but you can try restarting Tor or the web server, as it sometimes works for me.

Here, Iโ€™ll end this article, but if you have any questions or queries related to the topic, then do let me know in the comment section.

Till then, peace!

Join The Conversation

Users are always welcome to leave comments about the articles, whether they are questions, comments, constructive criticism, old information, or notices of typos. Please keep in mind that all comments are moderated according to our comment policy.