How to install Tor with Apache as a hidden service on a Raspberry Pi

Download Raspbian image

https://www.raspberrypi.org/downloads/raspbian/

You can use either the full or the lite image, it’s up to you.

Rpi installing images

https://www.raspberrypi.org/documentation/installation/installing-images/README.md

Choose your system. We’ll be using Linux + dd

Once that’s done, login to your pi using SSH with username: pi password: raspberry

Next install LAMP (Linux Apache, Mysql, and PHP).

https://www.raspberrypi.org/documentation/remote-access/web-server/apache.md

We don’t really need Mysql at this point, but it comes in handy. 🙂

Install PHP (we need it to run the gallery)

sudo apt-get install php5 libapache2-mod-php5

Next, we install Tor. Tor will route our existing Apache service over the Tor network.

sudo apt-get install tor

Once Tor is installed, we need to configure it use our Apache.

To become root either use sudo in front of every command to execute that command as root or use sudo -s to become root permanently.

We will edit the files using Nano editor. It has commands listed on the bottom. Ctrl + O is used to output the edited file.

The tor configuration file is located in the /etc/tor subdirectory. The /etc directory holds configuration files for all (most) Linux software.

sudo nano /etc/tor/torrc

Using the arrow keys or pagedown navigate to the part for setting up hidden services

############### This section is just for location-hidden services ###

“#” marks a commented line – Tor will skip this line when reading the configuration. Tu uncomment a line, simply delete the “#”
Uncomment the lines

#HiddenServiceDir /var/lib/tor/hidden_service/

This line specifies the location of the hidden service directory on you system. The default setting is OK.

#HiddenServicePort 80 127.0.0.1:80

This line specifies the port of the service we want routed through Tor. In our case, this is port 80, the default port for webservers. This can be changed in the Apache configuration file. Be sure to change this to mimic Apache’s port configuration.

Use Ctrl + o to write out what we edited. Don’t rename the file. Hit enter to confirm. Use Ctrl + x to exit Nano.

Now restart Tor using

sudo service tor restart

Tor has now generated an onion domain for your hidden service. You can check the domain by issuing

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

If you altered the HiddenServiceDir in the config file, use that.

You can now test your new onion domain by starting Tor browser and navigating to it. 🙂

Poopative Commons