Installing Two or More Tor hidden Services on an Ubuntu Server
How to Install Multiple Tor Hidden Services on Ubuntu Server (VirtualBox) Without a Panel
Introduction
Tor hidden services allow you to host websites that are only accessible through the Tor network, providing strong privacy and anonymity. In this guide, we will install and configure multiple hidden services on an Ubuntu server running inside a VirtualBox VM, set up a web server (Nginx, PHP, and MariaDB), and optionally install Webmin for simplified management.
1. Install VirtualBox and Create an Ubuntu VM
Before setting up the server, we need VirtualBox installed.
1.1 Download and Install VirtualBox
- Go to the VirtualBox official website:
👉 https://www.virtualbox.org/ - Download the latest version for your operating system.
- Install VirtualBox by following the installation wizard.
1.2 Create a New Ubuntu Virtual Machine
- Open VirtualBox and click “New”.
- Enter the name (e.g.,
Ubuntu Tor Server
). - Set Type to
Linux
and Version toUbuntu (64-bit)
. - Assign at least 2GB RAM (4GB recommended).
- Create a Virtual Hard Disk (20GB+ recommended).
- Select “Create”, then start the VM and install Ubuntu.
2. Install Required Software on Ubuntu Server
Once your Ubuntu VM is up and running, update the system:
sudo apt update && sudo apt upgrade -y
Now install Nginx, PHP, and MariaDB (LAMP/LEMP stack).
2.1 Install Nginx Web Server
sudo apt install nginx -y
sudo systemctl enable nginx
sudo systemctl start nginx
To verify that Nginx is running:
sudo systemctl status nginx
2.2 Install PHP and Required Modules
sudo apt install php php-fpm php-cli php-mysql php-curl php-xml php-mbstring -y
Start PHP service:
sudo systemctl enable php-fpm
sudo systemctl start php-fpm
2.3 Install MariaDB (MySQL Alternative)
sudo apt install mariadb-server -y
sudo systemctl enable mariadb
sudo systemctl start mariadb
Secure the database installation:
sudo mysql_secure_installation
During setup:
- Press
Enter
to use the default root password. - Choose
Y
to remove anonymous users and disallow remote root logins.
2.4 Create a Database and User
Login to MariaDB:
sudo mysql -u root -p
Create a new database and user:
CREATE DATABASE tor_db;
CREATE USER 'tor_user'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON tor_db.* TO 'tor_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
3. Install and Configure Tor for Hidden Services
3.1 Install Tor
sudo apt install tor -y
Enable and start Tor service:
sudo systemctl enable tor
sudo systemctl start tor
3.2 Configure Multiple Tor Hidden Services
Edit the Tor configuration file:
sudo nano /etc/tor/torrc
At the end of the file, add the following lines:
HiddenServiceDir /var/lib/tor/hidden_service1/
HiddenServicePort 80 127.0.0.1:8081
HiddenServiceDir /var/lib/tor/hidden_service2/
HiddenServicePort 80 127.0.0.1:8082
Save the file (CTRL + X
, then Y
, then Enter
).
Now restart Tor to apply the changes:
sudo systemctl restart tor
Tor will generate .onion
addresses for your hidden services. Retrieve them using:
cat /var/lib/tor/hidden_service1/hostname
cat /var/lib/tor/hidden_service2/hostname
4. Configure Nginx for Hidden Services
Create two server blocks for the hidden services.
4.1 Configure First Hidden Service
sudo nano /etc/nginx/sites-available/hidden_service1
Paste the following configuration:
server {
listen 8081;
server_name localhost;
root /var/www/hidden_service1;
index index.php index.html;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
4.2 Configure Second Hidden Service
sudo nano /etc/nginx/sites-available/hidden_service2
Paste the following configuration:
server {
listen 8082;
server_name localhost;
root /var/www/hidden_service2;
index index.php index.html;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
4.3 Enable Nginx Sites and Restart Server
sudo ln -s /etc/nginx/sites-available/hidden_service1 /etc/nginx/sites-enabled/
sudo ln -s /etc/nginx/sites-available/hidden_service2 /etc/nginx/sites-enabled/
Restart Nginx:
sudo systemctl restart nginx
5. Upload Files and Set Permissions
Create website directories:
sudo mkdir -p /var/www/hidden_service1
sudo mkdir -p /var/www/hidden_service2
Set ownership:
sudo chown -R www-data:www-data /var/www/
sudo chmod -R 755 /var/www/
Upload files using SCP from another machine:
scp index.html user@your_server:/var/www/hidden_service1/
6. (Optional) Install Webmin for Easier Server Management
wget https://prdownloads.sourceforge.net/webadmin/webmin_2.021_all.deb
sudo dpkg -i webmin_2.021_all.deb
sudo apt --fix-broken install -y
Access Webmin via:
https://your-server-ip:10000
or localhost:10000
Conclusion
Now, your multiple Tor hidden services are running on Ubuntu inside a VirtualBox VM. Each .onion
site is securely routed through Tor. You can manage files via SCP, configure Nginx for more sites, or use Webmin for additional convenience.
0 thoughts on “Installing Two or More Tor hidden Services on an Ubuntu Server”