Posted on Tuesday 25 July 2017 by Laposa UK

Install

$ 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

http://localhost: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 mywebserver.example.org -g -R 0.0.0.0:8081:localhost:8081

On public web server machine

vi /etc/apache2/sites-available/mywebserver.example.org-ssl.conf 

<IfModule mod_ssl.c>

<VirtualHost *:443>

    ServerName mywebserver.example.org

    VirtualDocumentRoot /srv/mywebserver.example.org/public_html

SSLCertificateFile /etc/letsencrypt/live/mywebserver.example.org/fullchain.pem

SSLCertificateKeyFile /etc/letsencrypt/live/mywebserver.example.org/privkey.pem

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

</VirtualHost>

</IfModule>

 

58 Howard Street
Belfast BT1 6PJ

Send email

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