At the end of the tutorial you will come up with something similar to this:
STEP1 Installing a webserver.
For this project we will use apache2 with the php extension. The apache server will host the html side that will be displayed to the user and the php server will execute the commands on our pi (like ‘gpio write 0 1’).
1.Step (receive the necessary packages:
sudo apt-get install apache2 php5 libapache2-mod-php5
2.Step (restart the webserver):
>sudo service apache2 restart
3.Step Varify that everything is working:
Open a browser on a different device in your local and enter the address of the pi. If you don't know the current address you can run the ifconfig command.
STEP2 Installing a ftp-server (Proftpd).
1.Step getting the nessary software:
sudo apt-get install proftpd
2.Step Choose run proftpd as Standalone
3.Step The proftpd package now needs to be adjusted to our needs:
sudo nano /etc/proftpd/proftpd.conf
4.Step We will add a virtual user called piftp thats why you have to add the following lines to the proftpd.conf file
DefaultRoot ~ AuthOrder mod_auth_file.c mod_auth_unix.c AuthUserFile /etc/proftpd/ftpd.passwd AuthPAM off RequireValidShell off
5.Step Before we can add our new user we need to change to the proftpd directory
6.Step Adding the new user (mine is called piftp). This command will also add the user to the group www-data (gid 33). Note After you entered the comment you will be asked for the password of the new user
sudo ftpasswd --passwd --name piftp --uid 33 --gid 33 --home /var/www/ --shell /bin/false
7.Step change the access rights to allow the piftp user to upload to the /var/www/ directory.
chmod g+s /var/www chmod 775 /var/www chown -R www-data:www-data /var/www
Last Step: Restart the Server
sudo /etc/init.d/proftpd restart
You should now be able to upload a file with an ftp client to your pi. The server address is the address of your pi. The port is 20, the user piftp and the password is the one that you entered in Step 6.
STEP 3 Installing the PiCam with mjpeg streamer.
# Make a new directory and change it. sudo mkdir /opt/mjpg-streamer cd /opt/mjpg-streamer/ # Install all the required packages sudo apt-get install libjpeg8-dev sudo apt-get install imagemagick sudo apt-get install subversion # Download MJPG Streamer into your active directory sudo svn co https://svn.code.sf.net/p/mjpg-streamer/code/mjpg-streamer/ . # Compile it by running the make command sudo make
STEP 4 Add the following script to you home directory, to automatically start the PiCam stream.
cd sudo nano AutoCam.sh
sudo nano /etc/rc.local
Add the following line:
After rebooting you should see the a red light at the camera lens. Further if you insert you pi’s ip-address + Port number (in my case 8080) into a browser on the same network, you should be now able to see the pictures of the camera.
STEP 5 Clone the code from github to your web-directory
Change to the the web directory
Clone the directory (You may need to install git)
git clone https://github.com/quaintproject/RaspberryPiTank.git
Now we are finished with the software part thats why I would suggest to move on to the hardware.
My current GPIO allocation, please mind if you want to use different functions it is necessary to change my suggestion towards your needs. Further note, not all pi versions have the P5 header.