- Blog entry posted in 'Uncategorised', January 20, 2013.
So now, we'll set up the Raspberry Pi as a web server, and additionally set up a blog using Nanoblogger, and set up TOR to put the web site on the TOR network. Depending on how much you want your web site to do, you may want to skip some of the packages i'm going to show being installed. For just a basic web server, all you really need is Apache, but for anything more, you will want the other packages as well. We'll begin with
Code:
apt-get install apache2 php5 libapache2-mod-php5
which will take care of what's needed for most basic web pages.
If you intend on doing any more than just basic web pages, for instance you want interactive web pages, you'll want to install MySQL:
Code:
apt-get install mysql-server mysql-client php5-mysql
And if you want to run a blog page, there are a few blog packages, but the simplest one is Nanoblogger, which runs from bash scripts.
Code:
apt-get install nanoblogger nanoblogger-extra
In Apache's default config, the place where you put all of your HTML files is /var/www, but since i already had a web page built on another machine, i edited the /etc/apache2/sites-available/default file to point to /var/www/htdocs, as well as include a 404 page i had made for it:
Code:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/htdocs #changed to match dir structure on another machine
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/htdocs/> #don't forget to change this one too if you change the one above
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
ErrorDocument 404 "/404.html" #this is the 404 page i added
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
So you can leave it as-is if you want and just put everything into /var/www instead, or change it to match whatever you have set up on another machine so you can just FTP the files to the Pi without disturbing the original directory structure.
If you know some HTML, you can make your own index.html file. I haven't looked to see what's available for Raspbian HTML editors, but if you have a "main" computer, you can use Mozilla Seamonkey's Composer, or some other WYSIWYG editor to create HTML pages, and then ftp them to the Pi.
Once you have an index.html page created, you can navigate a browser to the IP address of the Pi, and you will see the page you set up. The default page from Apache, just says "It works!"
If you downloaded Nanoblogger, open a root terminal, and type:
Code:
nb --blog-dir /var/www/weblog add weblog
Follow the instructions that the blog setup routine gives you,and nanoblogger will create a subdirectory /var/www/weblog/ and put a bunch of stuff under that directory. Once it's done, you should be able to navigate your browser to the blog page by adding /weblog.index.html after your Pi's IP address, for instance, on my Pi it would be
Code:
192.168.0.25/weblog/index.html
You should get a page that's the basic blog layout and some help for Nanoblogger commands. You can edit blog.conf and some of the template files to get things looking the way you want.
Now you can add the web site to TOR. The great thing about serving a web site on TOR is that you don't have to pay for a static IP address. The downside is that there aren't tens of millions of users of TOR (yet). You can use Vidalia to set up a hidden service pointed at port 80, or you can add the hidden service to the torrc file by adding:
Code:
HiddenServiceDir /home/pi/.vidalia/web/
HiddenServicePort 80 127.0.0.1:80
Once this has been added and TOR restarted,you should be able to go to the hidden service directory (/home/pi/.vidalia/web) and see a file called hostname. so to take a quick peek inside that file:
Code:
cat hostname
kbhngytxvr3lrmnz.onion
The 16 random characters are your web site's onion address. In a browser running through TOR, you can type in the onion address (including the .onion) and after a few moments, up will pop the web page. BTW, don't try that onion address shown, it doesn't exist, and i want to keep my anonymous blog on TOR, well, of course, anonymous...
So now, i'll leave you to create your web page, or blog, or whatever. If you have any questions about the Raspberry Pi, or any of the subjects i have covered, PM me.
BTW, shown below are a couple of 404 pages i made up.Comments