How to Setup a Tor Website
How to Setup a Tor Website
a raspberry pi,
or by following the steps in my video, “How to Setup a Remote Desktop in Bitclouds.”
ssh root@ipaddress
apt update -y && apt upgrade -y && apt autoremove -y
Install php (the language wordpress is written in), the php-fpm plugin (which lets php run in the
background), the php-mysql plugin (which lets php work with some database software that you
will probably install later if you decide to build a wordpress site), and nginx, which we will use as
our webserver.
Configure nginx. (If you are doing this on debian 9, see this document.) First remove the default
configuration file, because by default nginx isn’t set up to work with php, and then replace it by
running the subsequent “echo” commands, which will create a configuration file that is set up to
work with php.
rm /etc/nginx/sites-enabled/default
echo "server {" >> /etc/nginx/sites-enabled/default
echo " listen 80 default_server;" >> /etc/nginx/sites-enabled/default
echo " listen [::]:80 default_server;" >> /etc/nginx/sites-enabled/default
echo "" >> /etc/nginx/sites-enabled/default
echo " root /var/www/html;" >> /etc/nginx/sites-enabled/default
echo " index index.php index.html index.htm index.nginx-debian.html;" >>
/etc/nginx/sites-enabled/default
echo "" >> /etc/nginx/sites-enabled/default
echo " server_name _;" >> /etc/nginx/sites-enabled/default
echo "" >> /etc/nginx/sites-enabled/default
echo " location / {" >> /etc/nginx/sites-enabled/default
echo " try_files \$uri \$uri/ /index.php?q=\$uri&\$args;" >> /etc/nginx/sites-
enabled/default
echo " }" >> /etc/nginx/sites-enabled/default
echo "" >> /etc/nginx/sites-enabled/default
echo " location ~\.php$ {" >> /etc/nginx/sites-enabled/default
echo " include snippets/fastcgi-php.conf;" >> /etc/nginx/sites-enabled/default
In the next line, “php7.3-fpm.sock;” appears. It might need to be php7.2-fpm.sock; at least that’s
what worked in one of my tests on ubuntu. Initially php was not working, so I used the command
“whereis php7” to find out which version of php I was running. It said php7.2 on my ubuntu
machine so that’s what I put here and then everything worked fine. This part seems to me to be
the part of this tutorial that is most likely to change in the future. If/when php upgrades to php8
and then php9, etc., you may have to search for those instead of php7. After finding what
version of php you have by running whereis php7 (or php8 or php9, etc.), put the version
number that shows up when you run that command in place of 7.3 below.
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name _;
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location ~\.php {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
}
}
Install tor, which lets you publish your website on the world wide web so that any onion-enabled
browser can visit it.
Configure tor.
Technically you have a website now, though all it shows right now is the nginx welcome page.
We’ll change what your website shows in a minute, but you can find the onion address of your
website with the following command.
cat /var/lib/tor/tor_website/hostname
The result should be something like 44jfvjqw93jflk3.onion. Assuming you see such an address,
use any device that has an onion-compatible browser, such as the tor browser, to visit your
onion address and view your website.
You can add whatever files you want to serve (e.g. webpages) to /var/www/html/ For this
example I will download wordpress and create a basic wordpress site.
In order to run a wordpress site, we first need database software because wordpress is heavily
reliant on databases. I recommend mariadb because it is free, open source, and based on the
popular mysql program.
Run mariadb.
mariadb
On the next line, replace the word password with an actual, secure password.
Great! Now your database is installed and configured. The last thing we need to do is install
wordpress. First download it.
cd
wget https://wordpress.org/latest.tar.gz
Next unzip it and replace everything in your current html directory with wordpress.
Now you only need to visit your website in your onion-compatible browser to finish setup. Once
you’re there, select English as your language and click Continue, then click Let’s go! In the form
that follows, keep the database name as wordpress, change the username to admin, and
change the password to the one you set earlier when we were configuring mariadb. Keep the
database host as localhost and the table prefix as wp_. Then hit Submit. Now click Run the
Installation.
Give your site a title, e.g. Test Site, use admin as your username, and set a secure password.
Type your email and then decide if you want your site to be accessible to search engines. If you
don’t, check the box, otherwise keep it unchecked. Click Install WordPress. You’re done! You
can now login and manage your wordpress site at [your onion address].onion/wp-login.php, or
you can visit your onion address to view your website.