My Raspberry Pi
This page is mainly for myself. It's information pulled from many internet sources, condensed into what I would need to rebuild my Raspberry Pi.
What it does...
Webserver (Apache)
A place to host random stuff
Reverse proxy
Allows me to reach devices on my LAN from the internet....all using Apache's web port 80
GPS Server (gpsd)
Takes the serial NMEA string from my GPS receiver and shares it via TCP port 2947
APRS Gateway (aprx)
APRS traffic received on 144.39MHz is uplinked to the internet
MySQL Server
Web visitors IP address is used to determine which country they are in
The country names of the visitors are logged to MySQL and counted.
FTP Server
Makes it easy to transfer files
Webmin
Web interface to administer just about everything
phpMyAdmin
Web interface to administer MySQL
Data Paths...
144.39MHz RF
Comet DJ-130 discone antenna
Radio Shack Pro-2040
Kantonics Kam+
RS232 to USB
Raspberry Pi
APRX iGate
APRS-IS Network
Holux GR-213 GPS
Raspberry Pi
GPSd
Available to clients on TCP port 2947
The Hardware
512MB Raspberry Pi Model B Project Board
Raspberry Pi VESA Mount Case
Wheezy Raspbian on an 16GB SD card
Wi-Pi 802.11n Wireless Adapter (USB)
Logitech MK520 Wireless Keyboard and Mouse (USB)
Holux GR-213 GPS (USB)
Initial Setup
Obtain a copy of the Raspberry Pi OS
Burn the image to the SD card using Win 32 Disc Imager
Install SD card, power up & log in.
The default username is "pi", and the default password is "raspberry".
Update the clock, update our sources, then upgrade any
pre-installed packages
sudo dpkg-reconfigure tzdata
sudo apt-get update
sudo apt-get upgrade
Keep the Firmware Up To Date using Hexxeh's RPI update tool
sudo apt-get install ca-certificates
sudo apt-get install git-core
sudo wget http://goo.gl/1BOfJ -O /usr/bin/rpi-update && sudo chmod +x /usr/bin/rpi-update
sudo rpi-update
sudo shutdown -r now
Open up your SSH client and connect to the Raspberry Pi's IP address
Change the password
sudo passwd pi
Configure a static IP
sudo nano /etc/network/interfaces
Change "iface eth0 inet dhcp" to "iface eth0 inet static"
Add the following:
address 192.168.100.1
netmask 255.255.255.0
network 192.168.100.0
broadcast 192.168.100.255
gateway 192.168.100.254
Servers
Apache Web Server
sudo apt-get install apache2 php5 libapache2-mod-php5
Now restart the service:
sudo service apache2 restart
Take ownership of the web root:
sudo chown -R pi /var/www
Install PHP:
sudo apt-get install php5-cgi
MySQL
sudo apt-get install mysql-server mysql-client php5-mysql
FTP
sudo apt-get install vsftpd
Configure FTP
sudo nano /etc/vsftpd.conf'
Change anonymous_enable=YES to anonymous_enable=NO
Uncomment local_enable=YES
Uncomment write_enable=YES
At the end of the file add force_dot_files=YES
Save and exit the file.
sudo service vsftpd restart
Enable Root Account
sudo passwd root
User Pi Configuration
Log out of your SSH session, and log back in as root
nano /etc/passwd
Find the line pi:x;1000:1000:Raspberry Pi User,,,:home/pi:/bin/bash and add
a # sign to the beginning of it.
Save and exit the file.
usermod -d /var/www pi
Now exit your SSH session, and log back in as pi, then grant mod rights to
root.
sudo usermod -L root
GPSD
sudo apt-get install gpsd gpsd-clients
Login as root
Connect gpsd to the USB GPS and make it available to local &
remote clients on TCP port 2947
gpsd -G -n /dev/ttyUSB0
Make gpsd start automatically (enter the settings above when
prompted)
dpkg-reconfigure gpsd
Setup permissions for the USB device
sudo nano /lib/udev/gpsd.hotplug
add "chmod a+rw $DEVNAME" before "gpsdctl $ACTION $DEVNAME" near the end of
the file
Apache Reverse Proxy
sudo apt-get install libapache2-mod-proxy-html
a2enmod proxy
a2enmod proxy_http
a2enmod rewrite
sudo nano /etc/apt/sources.list
Add
deb http://ftp.debian.org/debian lenny main contrib non-free
deb http://security.debian.org lenny/updates main contrib non-free
deb http://volatile.debian.org/debian-volatile lenny/volatile main contrib
non-free
deb http://www.backports.org/debian lenny-backports main contrib non-free
apt-get update
apt-get install libapache2-mod-proxy-html
sudo nano /etc/apt/sources.list
Comment or delete the sources you added
apt-get update
/etc/init.d/apache2 reload
Look in /etc/apache2/mods-enabled to see which mods were installed.
a2enmod proxy
a2enmod proxy_http
/etc/init.d/apache2 restart
Hosts
Enter any hosts IP addresses (static) and machine names that exist on your
network
sudo nano /etc/hosts
Create /etc/apache2/conf.d/httpd.conf so Apache can
determine it's domain name
sudo nano /etc/apache2/conf.d/httpd.conf
Add "ServerName localhost", save and exit
Webmin
sudo nano /etc/apt/sources.list
Add
deb http://download.webmin.com/download/repository sarge contrib
deb http://webmin.mirror.somersettechsolutions.co.uk/repository sarge
contrib
Obtain and install the GPG key with which the repository
holding Webmin is signed
cd /root
wget http://www.webmin.com/jcameron-key.asc
sudo apt-key add jcameron-key.asc
Get system updates
sudo apt-get update
sudo apt-get install webmin
Wireless Access Point
sudo apt-get install hostapd isc-dhcp-server
sudo nano /etc/dhcp/dhcpd.conf
Comment these lines (with a #)
#option domain-name "example.org";
#option domain-name-servers ns1.example.org, ns2.example.org;
Remove the comment from
authoritative;
Scroll down to the bottom and add the following lines
subnet 192.168.11.0 netmask 255.255.255.0 {
range 192.168.11.100 192.168.11.150;
option broadcast-address 192.168.11.255;
option routers 192.168.11.1;
default-lease-time 600;
max-lease-time 7200;
option domain-name "local";
option domain-name-servers 8.8.8.8, 8.8.4.4;
}
sudo nano /etc/default/isc-dhcp-server
scroll down to INTERFACES="" and update it to say INTERFACES="wlan0"
sudo ifdown wlan0
sudo nano /etc/network/interfaces
Find the line auto wlan0 and add a # in front of the line, and in front of
every line afterwards
Add these lines after "allow hotplug wlan0"
iface wlan0 inet static
address 192.168.11.1
netmask 255.255.255.0
Assign a static IP address to the wifi adapter by running
sudo ifconfig wlan0 192.168.11.1
sudo nano /etc/hostapd/hostapd.conf
Add the following:
interface=wlan0
driver=rtl871xdrv
ssid=Pi_AP
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=Raspberry
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
sudo nano /etc/default/hostapd
Edit it so it says DAEMON_CONF="/etc/hostapd/hostapd.conf"
sudo nano /etc/sysctl.conf
Scroll to the bottom and add "net.ipv4.ip_forward=1"
sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
sudo nano /etc/network/interfaces
Add to the end of the file :
up iptables-restore < /etc/iptables.ipv4.nat
wget
http://www.adafruit.com/downloads/adafruit_hostapd.zip
unzip adafruit_hostapd.zip
sudo mv /usr/sbin/hostapd /usr/sbin/hostapd.ORIG
sudo mv hostapd /usr/sbin
sudo chmod 755 /usr/sbin/hostapd
sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf
Useful commands
View the startup log
dmesg
Watch hotplug events
tail -f /var/log/syslog
Login to MySQL
mysql -h localhost -u root -p[password]
Import .csv file into MySQL
LOAD DATA INFILE '/raspberry/Databases/ip-to-country.csv' replace INTO TABLE
ip_to_country FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY
'\r\n';