Posted on Tuesday 25 July 2017 by Laposa UK


$ apt install motion

$ vi /etc/motion/motion.conf

Find the following lines and make the following changes. 

  • daemon on 

$ vi /etc/default/motion

Make the following change:

  • start_motion_daemon=no -> start_motion_daemon=yes

Next we need to make sure the motion capture directory is writable

$ chmod 777 /var/lib/motion

Now make sure the camera is connected and start the service with the command:

$ service motion start

To stop the service, the command is:

$ service motion stop

Check locally

Now you can view the camera from a browser on the Pi (or other computer if stream_localhost was set to off) by connecting to your Pi’s IP address and Motion’s default port 8081


Make available from public web server

On motion machine

$ crontab -e 

@reboot /usr/local/bin/open_tunel &

$ vi /usr/local/bin/open_tunel

#!/bin/sh -e
autossh -M 0 -f -T -N -g -R

On public web server machine

vi /etc/apache2/sites-available/ 

<IfModule mod_ssl.c>

<VirtualHost *:443>


    VirtualDocumentRoot /srv/

SSLCertificateFile /etc/letsencrypt/live/

SSLCertificateKeyFile /etc/letsencrypt/live/

Include /etc/letsencrypt/options-ssl-apache.conf


    ProxyPass /motion http://localhost:8081

    ProxyPassReverse /motion http://localhost:8081


    ProxyPass /motion.jpeg http://localhost:8081

    ProxyPassReverse /motion.jpeg http://localhost:8081




58 Howard Street
Belfast BT1 6PJ

Send email

+44 (28) 9032 8988
+353 (48) 9032 8988