Raspberry Pi

Raspberry Pi (RPi) Single Board Computer

Installing Apache Web Server on a RPI


Install Apache

First install the apache2 package by typing the following command in to the Terminal:

sudo apt-get install apache2 -y

Test the web server



Apache success message

This means you have Apache working!

Changing the default web page

This default web page is just a HTML file on the filesystem. It is located at /var/www/html/index.html.

Note: The directory was /var/www in Raspbian Wheezy but is now /var/www/html in Raspbian Jessie

Navigate to this directory in the Terminal and have a look at what’s inside:
cd /var/www/html
ls -al

This will show you:
total 12

This shows that there is one file in /var/www/html/ called index.html. The . refers to the directory itself /var/www/html and the .. refers to the parent directory /www/.

What the columns mean
1.The permissions of the file or directory
2.The number of files in the directory (or 1 if it’s a file).
3.The user which owns the file or directory
4.The group which owns the file or directory
5.The file size
6.The last modification date & time

By default the html directory and index.html file are both owned by the root user. In order to edit the file, you must gain root permissions. Change the owner to your own user with sudo chown pi: index.html before editing.

Try editing this file and refreshing the browser to see the web page change.

Your own website


Additional – install PHP

To allow your Apache server to process PHP files, you’ll need to install PHP5 and the PHP5 module for Apache. Type the following command to install these:

Now remove the index.html file:
sudo rm index.html

and create the file index.php:
sudo leafpad index.php

Note: Leafpad is a graphical editor. Alternatively, use nano if you’re restricted to the command line

Put some PHP content in it:
<?php echo “hello world”; ?>


or show your PHP info:
<?php phpinfo(); ?>
Install PHP-GD (graphics support:
sudo apt-get install php5-gd

Further – WordPress


Installing WEEWX Server on a RPI



Install with the command:
sudo dpkg -i weewx_X.Y.Z-R_all.deb


sudo apt-get update
sudo apt-get -f install


Check Status

sudo tail -f /var/log/syslog







weewx must be restarted for configuration file changes to take effect.


To start/stop weewx:
sudo /etc/init.d/weewx start
sudo /etc/init.d/weewx stop


To uninstall weewx but retain configuration files and data:
sudo dpkg -r weewx

To uninstall weewx, removing configuration files but retaining data:
sudo dpkg –purge weewx

To remove data:
sudo rm -r /var/lib/weewx
sudo rm -r /var/www/html/weewx


The installation will result in the following layout:

executable: /usr/bin/weewxd
configuration file: /etc/weewx/weewx.conf
skins and templates: /etc/weewx/skins
sqlite databases: /var/lib/weewx/
documentation: /usr/share/doc/weewx/
utilities: /usr/bin/wee_*

Setting up Dynamic DNS forwarding of Rpi IP address to FreeDNS

Set up your Direct URL from the Free Dynamic DNS account that you need to create.

Log in to your account at afraid.freedns.org and click Dynamic dns on the left pane. Scroll down and you will see a Direct URL hyperlink. The link looks something like this http://freedns.afraid.org/dynamic/update.php?HTPCGuidesSecretKey.


We will create a cronjob to run every 5 minutes and update your free dynamic DNS with your current IP address

Paste the code below but replace the URL http://freedns.afraid.org/dynamic/update.php?HTPCGuides with your direct link URL you copied to the clipboard.
crontab -l | { cat; echo “*/20 * * * * curl http://freedns.afraid.org/dynamic/update.php?HTPCGuides”; } | crontab –

You will get a message that looks like an error but it isn’t so don’t worry.
no crontab for pi/code

To verify that the command before added the cronjob you can list the cron jobs to make sure the freedns job is there
crontab -l

It should show


Restart the cron service
sudo service cron restart

You can adjust the update interval by modifying the */20 to */60 for every 60 minutes or whatever interval you need.

FREEDNS has full instructions on this method too.

Installing an FTP Server


Install Pure-FTPd

sudo apt-get install pure-ftpd

Basic Configurations

groupadd ftpgroup

FTP Home Directory, Virtual User, and User Group

sudo mkdir /home/pi/FTP

Make sure the directory is accessible for ftpuser:
sudo chown -R ftpuser:ftpgroup /home/pi/FTP


sudo pure-pw mkdb


Restart the program:
sudo service pure-ftpd restart

Test it with an FTP client, like FileZilla.

More Detailed Configurations:

sudo nano /etc/pure-ftpd/conf/ChrootEveryone



Make a file named NoAnonymous and type yes;

Make a file named AnonymousCantUpload and type yes;

Make a file named AnonymousCanCreateDirs and type no;

Make a file named DisplayDotFiles and typeno;

Make a file named DontResolve and type yes;

Make a file named ProhibitDotFilesRead and type yes;

Make a file named ProhibitDotFilesWrite and type yes;

Make a file named FSCharset and typeUTF-8;

Restart pure-ftpd again and apply the above settings.
sudo service pure-ftpd restart


Adding Image Uploads to Weather Underground

  2. Save and exit
  3. Make the script file executable:
    1. sudo chmod +x wunder.sh
  4. Create a PYTHON script file:
    1. sudo nano wunder.py
    2. Add to the file the following:
      1. #!/usr/bin/env pythonimport shutil
        import os
  5. Make the PYTHON script executable:
    1. sudo chmod -x wunder.py
    2. Add the following for 15-min updates intervals:
  7. FInished

Weewx General Topics

Corrupt station memory


adjust paths as necessary: wee_device –clear-memory

Weewx and running a report on-demand

sudo wee_reports /etc/weewx/weewx.conf

Camera Installation