Customised Raspberry Pi
Image for SJWMS

These notes and the customised image may be freely used for educational purposes.
Commercial use is not permitted. B. Reay Nov. 2012





Introduction

These notes accompany a customised software 'image' for the Raspberry Pi. The image was developed as a
favour to a colleague in my school. The primary aim was to remove the need for additional keyboards and
monitors when using a Raspberry Pi by the use of “SSH” and “X-Windows”. The project was extended to
include the provision of a webserver and supporting FTP client.

The initial passwords are raspberry and vncvncpw (for the vnc server).


Checking the System is Up To Date


The following commands will help keep the Raspberry Pi Linux up to date:

sudo apt-get update

Followed by:

sudo apt-get upgrade

For a distribution upgrade:

sudo apt-get dist-upgrade

Enabling SSH

SSH is not enabled in the standard Debian image. To enable it the following is required:

sudo mv /boot/boot_enable_ssh.rc /boot/boot.rc
sudo shutdowin -r now

Once SSH is enabled, you can use an SSH client from a PC, Mac or Ipad to open an SSH session over the
network to the Raspberry Pi.

Clients tested are: PC: PuTTY, Ipad: Zalink, Mac: inbuilt terminal programme.

VNC Server

Install the Tight Vnc Server from the command prompt:

sudo apt-get install tightvncserver

When it completes start the server:

vncserver

You'll be asked to create a password, enter one and confirm.

(There is an option for a view only password, which I ignored- no.)

You can start up a VNC client on a PC, Mac, Ipad etc. and check it works. You will need to enter
your_raspberry_IP:1 (the :1 is for the display or server number, at this stage there is only one).

To run the VNC server automatically, we need a script which can be run at boot up.

This is an EXAMPLE of the basic script:
#!/bin/sh
# /etc/init.d/tightvncserver
VNCUSER='pi'
case "$1" in
    start)
    su $VNCUSER -c '/usr/bin/tightvncserver :1'
    echo "Starting TightVNC Server for $VNCUSER "
    ;;
    stop)
    pkill Xtightvnc
    echo "TightVNC Server stopped"
    ;;
    *)
    echo "Usage: /etc/init.d/tightvncserver {start|stop}"
    exit 1
    ;;
esac
exit 0

NOTE: There are actually two versions of the script, on for the pi user and on for the root user. They differ in
the environment variable VNCUSER and 'display number', :1 is for the pi user, :2 is for the root user.

You can edit the display geometry, see below.

Both scripts are located in: /etc/init.d/ and have 755 permissions

They are called:
tightserver pi user
tightserver2 root user

The terminal settings are:

su $VNCUSER -c '/usr/bin/tightvncserver :1 -geometry 800x600 -depth 24

OR

su $VNCUSER -c '/usr/bin/tightvncserver :2 -geometry 800x600 -depth 24'

To ensure they are executed at boot, the following is required:

sudo update-rc.d tightvncserver defaults

The tightvncserver can be started or stopped manually from the command prompt with:

sudo /etc/init.d/tightvncserver start

sudo /etc/init.d/tightvncserver stop

You can now connect to the Rasperry Pi from a PC, Mac, Ipad etc. running a suitable VNC client. The
configuration has been tested with a PC under Windows and Linux with VNC, Mac and VNC and Ipad with
VNC. For the Ipad you really need an external keyboard.

Note: The initial password is set to vncvncpw


FTP Server


We need to install an FTP server. The one I used is Proftp. This runs as a 'daemon' at boot up and the
installation initiates the daemon for us.

sudo apt-get install proftpd

When asked, select “stand alone mode”.

Once it is finished installing, you can check it is working with:

sudo service proftpd status

This should report the server is running.

You can now use an FTP client to connect to the Raspberry Pi to transfer files. Tested PC client: Terrapin and Linux client Filezilla.


Web Server


There are several web servers, Apache is as good as any.

sudo apt-get install apache2

You will see an error at first due to user permissions etc. That is about to be addressed.

You need to create a directory in the pi user area for the web server files. This can be done under the
'windows' file manager or at the command prompt.

/home/pi/ www


The apache file needs a couple of lines editing:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
        DocumentRoot /home/pi/www 
<<<HERE
            <Directory />
                Options FollowSymLinks
                AllowOverride None
            </Directory>
        <Directory /home/pi/www/>  
<<<HERE
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all




We also need to tell Apache that pi is 'authorised' to run it by editing the file:
/etc/apache2/envvars

The changes are:

#export APACHE_RUN_USER=www-data  
<<<<insert #
#export APACHE_RUN_GROUP=www-data
<<<<insert #
export APACHE_RUN_USER=pi      <<<<insert new line
export APACHE_RUN_GROUP=pi   <<<<insert new line

 

There is a remaining minor issue which is unsolved. It should be partially cleared by editing:
/etc/apache2/httpd.conf

To read:
ServerName localhost

However, this does not clear the problem but it only causes is an error message on boot. The server runs. I
assume it is an issue with Apache on the Pi.

The Apache server will 'pick up' the above changes at the next boot up or you can stop and restart it with:

sudo service apache2 stop

sudo service apache2 start
(You can ignore the 'local host error', see above.)

To check the server is running:

sudo service apache2 status

After the above changes, an index.htm file can be placed in the /home/pi/www directory.
Note: An initial page is supplied with the image, it summarises the facilities the software offers.