LAMP (Linux, Apache, MySQL and PHP) on Raspberry PI

Install LAMP (Linux, Apache, MySQL and PHP)

From:  <>

Install Apache

sudo apt-get install apache2 -y

Install PHP
Test by going http://localhost/ or http://raspberrypi/ if installing trough SSH

sudo apt-get install php5 libapache2-mod-php5 -y
sudo apt-get install php5-gd -y

Restart apache

sudo /etc/init.d/apache2 restart

Test PHP

sudo nano /var/www/html/testphp.php

Paste this in file

<?php phpinfo(); ?>

Ctrl-X and save

And test http://raspberrypi/testphp.php

You should see php info page

Install MySQL

sudo apt-get install mysql-server -y

Set root password for MySQL root during the installation

Install phpMyAdmin

sudo apt-get install php5-mysql phpmyadmin -y

Create database

  • Choose apache2
  • And give and set password

Test http://raspberrypi/phpmyadmin user:root pass:<your-pass>

How to install or upgrade UV4L on Raspbian Wheezy & Raspbian Jessie for Raspberry Pi

How to install or upgrade UV4L on Raspbian Wheezy & Raspbian Jessie for Raspberry Pi

The following instructions refers to installing UV4L on the official Raspbian Linux distributions for any flavour of Raspberry Pi (1, 2, 3, Compute Module, etc…). As these installation instructions are updated and improved very frequently, it is suggested to read them from scratch in case of problems and especially whenever a new UV4L module is announced.

Lähde: Linux Projects – Documentation

Ambient light on Raspberry Pi running Openelec with APA102 Led strip

Raspberry Pi running Ambient light


On this article I will assume that openelec is already installed on Pi. Openelec image can be found from Raspberry Pi downloads or directly from get-openelec.

On my build I am taking power to APA102 led strip directly from RPi. That is now the way it should be done but it seems to work.

My configuration based on configuration used with WS2801 LED strip.
On Raspberry Pi 2 MOSI and SCLK pins are at the same position.


Hyperion is used to control led strip

Install Hyperion, see instructions on

On SSH command line get installation file

curl -L --output --get

And run it

sh ./

Hyperion configuration

Create configuration file by using HyperCon. See instructions on Git page

To be able to use apa102 led strip following configuration changes need to be made on HyperCon








RGB Byte order:



Rest of the configuration on this page depend how many leds are used and how those are constructed. See more instructions from HyperCon Git


On Effect engine set




On created hyperion.config.json file change Type from Adalight to apa102


And copy created configuration file hyperion.config.json in Openelec directory /storage/.config

Since we are using apa102 Leds we need to enable SPI on raspberry Pi. By default SPI is not available.

On SSH command line

mount -o remount,rw /flash
nano /flash/config.txt

At the end of file add


Press Ctrl-x , Y , Enter to save changes

Set directory readonly

mount -o remount,ro /flash

And reboot Pi


When Openelec start led strip should show rainbow colors and Ambient light should be running.



Raspberry Pi motion detection IR Camera with IR lights


Raspberry Pi camera module with PIR motion detector with external IR Lights

  • HW version 2.0
  • SW version 1.7.1

Camera shoot video as long movement is detected and take image every 10 minutes.

Application takes care that old recordings are removed and there is always enough disk space available. The amount of free disk space can be set on application settings.

This work is still in progress. Next I am planning to add possibility to store recordings on external server and change the schematic so that single 12V power is used instead of 5V and 12V  which are used in this configuration.


  • Raspberry Pi
  • Raspberry Pi noir camera
  • HC-SR501 Adjust Pyroelectric Infrared IR PIR Motion Sensor Detector
  • 48 LED illuminator IR Infrared Night Vision
  • Switch
    • DB681 darlington transistor
    • 2,2 kΩ resistor
    • 1000 µF capacitor

The total cost of camera is around 70€

The related code is published at GitHub



The idea in this configuration is that when motion is detected python application gets information of it and it will turn the illuminator on and start recording. Recording continue until movement is no longer detected.

The whole system is packed into standard casing since I don’t have 3D printer to create custom case.

RaspCam08 RaspCam07

I used TIP 120 based configurations as a base of my build. Since TIP 120 was not available locally I used DB681 darlington transistor instead. The 1000 µF capacitor was added to remove flicker. Without capacitor it light was flickering when standard 12v power source was used.


The switch was build on separate board and connected to Raspberry Pi and insulated from Pi by using bike tire inner tube. On my original build switch was located on separate case.

RaspCam01 RaspCam02 RaspCam03 RaspCam05 RaspCam06

In this configuration PIR is connected on 5v, GND and GPIO4. Switch uses GPIO 24.


Raspberry Pi USB Picture Frame

Raspberry Pi USB picture frame

Raspberry Pi plays automatically images from inserted USB flash drive and is shutdown by pressing the button inserted into the device.

feh is used to display the images from USB and python script to shut down the device.

I collected tips from several pages and try to list as many of them at the end of this article.

Prepare Raspberry Pi

Install standard rasbian package from by following the image installation guide. NOOBS will do just fine too.

Setup Raspberry Pi according to your preferences. Only thing to ensure is that Raspberry start on GUI. Instructions can be found also from You need keyboard on first startup.

You can use either console directly from Raspberry Pi or as I prefer SSH to connect the device. My preferred SSH client is MobaXterm.

Install feh and setup startup files

Update rasbian and install feh. Network connection is needed.
sudo apt-get update sudo apt-get upgrade sudo apt-get install feh

Create mount point

Mount point is needed to ensure all USB flash drives are treated same way. If USB is not mounted it will show under media as the way flash drive is named. For example KINGSTON would be ’/media/KINGSTON’ and could not be detected by feh if different flash drive was used previously

sudo mkdir /media/usb


This phase can be skipped if button is not used to shutdown Raspberry Pi. I do recommend using this since shutting down the Raspberry Pi simply by unplucking the device can cause the SD or USB flash drive corruption.

Connecting the GPIO 17 to the ground will cause shutdown to be performed. You may use other pins also but code need to be changed accordingly.



nano shutdown py

And paste the following code

import RPi.GPIO as GPIO
import time
import os
# GPIO 17 = pin 11
# GND = pin 9
GPIO.setup(17, GPIO.IN,pull_up_down=GPIO.PUD_UP)
while True:
    print GPIO.input(17)
    if(GPIO.input(17) == False):
        os.system("sudo shutdown -h now")

Ctrl-x and Yes and Enter to close editor and save changes

Update rc.local

Update rc-local so that USB is automatically mounted and is loaded at startup

sudo nano /etc/rc.local

Into the rc.local before ’exit 0’ add the following lines to mount USB flash drive and to start on background process

sudo mount /dev/sda1 /media/usb
sudo python /home/pi/ &

Update LXDE autostart

Update LXDE so that feh is started automatically on startup

This doesn’t seem to work anymore with rasbian jessie

sudo nano /etc/xdg/lxsession/LXDE-pi/autostart

But this one does

sudo nano ~/.config/lxsession/LXDE-pi/autostart

Instert following lines at the end of autostart

@xset s off
@xset -dpms
@xset s noblank
@feh --quiet --fullscreen --borderless --hide-pointer --slideshow-delay 30 /media/usb/


Mount USB by running

sudo mount /dev/sda1 /media/usb

And see if you can see the content of USB drive

ls /media/usb

Test feh by running following on command line. You need to have pictures on USB 🙂

feh --quiet --fullscreen --borderless --hide-pointer --slideshow-delay 1 /media/usb/

Test shutdown by running

sudo python

and connecting the proper pins.

Addition to original post

To turn TV on and off trough HDMI CEC

Install cec-utils:

sudo apt-get install cec-utils

add following lines in crontab -e

# Turn TV on
0 8 * * 1-5 echo "on 0" | cec-client -s
# Turn TV off
0 16 * * 1-5 echo "standby 0" | cec-client -s

This worked fine with TV


The Raspberry Pi A+ works fine with feh and USB flash drive. Simple configuration without anything fancy. Just power on the Pi and images start to roll directly from USB and it can be shutdown properly by connecting the 9 and 11 pins (button).


What next

A lot could be done. I tested already some digital signage solutions but for my use case this one was the most convenient especially since my goal was to get my Raspberry Pi A+ in good use. I did all the tasks mentioned in this article in my Raspberry Pi 2 since it is so much faster and have ethernet port build in and used the A+ after everything was ready. 🙂

Possibility to fetch images from some external source can be reached with feh and insertion of USB while feh is running. Just keep reading the references and other sources.

Starting the RPi by connecting the run pins could be added so that power doesn’t need to be removed and reconnected. One button to shutdown RPi and another to start it up again. RPi uses very little power when it is on idle.

Perhaps archinux could be used instead of rasbian?


  1. by johnnygal
  2. Pinouts for all Pi models from
  3. Digital Frame instructions
  4. Feh  and documentation
  5. 16 slices of Rasberry Pi for Digital Signage
  6. Digital Signage projects
  7. Instructables