Setting Up a Tor Onion Site on Linux

Post Reply
ianadmin
Site Admin
Posts: 4
Joined: Thu Aug 27, 2026 10:46 am

Setting Up a Tor Onion Site on Linux

Post by ianadmin »

If you want to have a .onion site, here is how to do it. I will make another post about why you should use a .onion site for privacy and anonymity reasons later.
It is fairly easy to set up the .onion site. If you have set up a website before then you will not have any problems with this. If you have never set up a website before, I would first learn how to set up a web server (I recommend learning Apache or NGINX) before following along. I would also recommend learning about virtual hosts at the same time.
So, this is what you will need and know (or be familiar with) the following:
• A Linux computer, server, or Raspberry Pi
• A working Internet connection
• A web server such as NGINX or Apache
• Basic Linux command-line knowledge
• Familiarity with sudo
• Basic knowledge of Linux permissions
• Some experience editing configuration files with nano or vim
• SSH knowledge if you're administering the machine remotely
• Basic understanding of HTTP/HTTPS
• Basic familiarity with NGINX or Apache configuration
I am basing this tutorial on the fact that you already have a web server set up and running on a Linux computer. I us Ubuntu so these commands work there; if you are using another Linux distribution, you may have to adjust some of your commands and directory/file locations. I also use vim as my text editor, so adjust your commands if you prefer another text editor.
Before installing Tor, update your system:
$sudo apt update
$sudo apt full-upgrade
$sudo apt clean
$sudo apt autoremove
Next, we install Tor (this step is installing the Tor server software and not the Tor browser):
$sudo apt install tor
Once you have Tor installed, check it’s status:
$sudo systemctl status tor
If it isn’t active/enabled, run the following commands:
$sudo systemctl start tor
$sudo systemctl enable tor
You’ll now have to configure the onion service. Do this by editing the “torrc” file:
$sudo vi /etc/tor/torrc
Add/change/uncomment the following:
HiddenServiceDir /var/lib/tor/my-website/
HiddenServicePort 80 127.0.0.1:80
Save the file and restart Tor:
$sudo systemctl restart tor
Then check the service again:
$sudo systemctl status tor
Now that you have created the onion service, you will find your .onion address in the hostname directory. For this next step, you will either have to su to the root/debian-tor user or change the permissions to allow you to edit the file.
$sudo cat /var/lib/tor/my-website/hostname
This will output an address ending in:
.onion (i.e. abcdefghijklmnopqrstuvwxyz1234567890abcdef.onion
Now you have to configure your web server (Apache or NGINX):
NGINX:
Create a site configuration:
$sudo nano /etc/nginx/sites-available/myonionsite
A basic configuration could look like this:
server {
listen 127.0.0.1:80;
server_name _;
root /var/www/myonionsite/public_html;
index index.html;
# Reduce unnecessary server information
server_tokens off;

location / {
try_files $uri $uri/ =404;
}
}
Create the website directory:
$sudo mkdir -p /var/www/myonionsite/public_html
Enable the site:
$sudo ln -s /etc/nginx/sites-available/myonionsite \
/etc/nginx/sites-enabled/myonionsite
Test the NGINX configuration:
$sudo nginx -t
If the test succeeds, reload NGINX:
$sudo systemctl reload nginx
For Apache:
$sudo vi /etc/apache2/sites-available/myonionsite.conf
<VirtualHost *:80>
ServerName your-onion-address.onion
DocumentRoot /var/www/myonionsite/public_html
<Directory /var/www/myonionsite/public_html>
AllowOverride None
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/myonionsite-error.log
</VirtualHost>
Enable the site:
$sudo a2ensite myonionsite.conf
Check the Apache configuration:
$sudo apache2ctl configtest
If everything is OK, restart Apache:
sudo systemctl restart apache2
Create a test index file:
$sudo nano /var/www/myonionsite/public_html/index.html
Add:
<!DOCTYPE html>
<html>
<head>
<title>Welcome to My Onion Site!</title>
</head>
<body>
<h1>Success!</h1>
<p>Your Onion Service is working.</p>
</body>
</html>
You will be able to access your new .onion site through the Tor network. If you don’t know how to do this, look for other posts on this.
Post Reply