Goals for this Blog
Continuing on from my last blog, this time I will be installing and configuring the web server and database. For these, I have decided on using lighttpd for the web server and SQLite3 for the database. The reasoning behind using these two packages, are they are both lightweight and use very little system resources. This is something I learned back with Pi1’s… Originally I was a Apache and MySQL fan, but struggled to keep these running on the Pi1 and then changed over. That leads to my second reason to why I chose lighted and SQLite3 - I am comfortable in using and configuring them and they are reliable.
Web Server - lighttpd
Installing the basic web server is quite easy.
$ sudo apt-get update
$ sudo apt-get install lighttpd
And that’s it - if you want to load your static webpage in /var/www/html/ directory it will be available through your web browser at http://192.168.100.20
Now to make it more usable, I will install php7 this will allow server side scripting which also allows for access to database stored data.
$ sudo apt-get install php7.0-fpm php7.0-cgi
NOTE: I don’t run the following apt-get install php7.0 as by default will also install apache2 and not the two actually required packages for lighttpd.
Now, to enable php7, you have to enable the modules in the lighttpd configuration.
$ cd /etc/lighttpd
$ sudo cp conf-available/10-fastcgi.conf conf-enabled/
$ sudo cp conf-available/15-fastcgi-php.conf conf-enabled/
Restart the lighttpd web server
$sudo systemctl restart lighttpd
To test that everything is working so far, we can create a php info file in the default directory and check it out in our web browser.
$ cd /var/www/html
$ sudo vim
Placing the following in that file
<?php
phpinfo();
?>
Save it as phptest.php
On your browser, go to
http://192.168.100.20/testphp.php
And you should get a whole bunch of stuff about your system and php.
Database Server - SQLite3
Following on from the web server installation, we can now move onto install the database server.
$ sudo apt-get install sqlite3 php7.0-sqlite3
This will install both the SQLite3 server and the required packages to link SQLite3 to PHP7
And that is it, you can test the database installation by running
$ sqlite3 testdb.sqlite
That will put you into the SQLite3 CLI and create a blank database file.
Type .exit (noting the . ) to exit the CLI
Again, you will ned to restart the web server to enable the newly install php7.0-sqlite3 package and I will go through the web design and creation of the database in a later blog.
Conclusion
That wraps up the basic software installation for the SafeDegree Controller. It still leaves it as a pretty ‘dumb’ controller at this stage, but in later blogs, it will all start to come together.
For my next blog, I will begin working on the software side of the SafeDegree temperature sensor module.