Linux – Lighttpd – Sqlite3 – PHP
The Beaglebone Black is rather powerful when you consider it only needs 5v to operate, aside from its many possibilities when using its onboard headers to control most any thing you can imagine, it also runs a full operating system such as Ubuntu or Debian among others, allowing you to take advantage of many of the additional software packages available to Ubuntu. the ever popular L.A.M.P. server is lots of fun when developing a local web server and is almost a must when your creating web based projects, as it is possible to run such a server on your Beaglebone Black, it is a bit heavy and runs a mite slow, however it does work.
However there is an alternative, you can install and setup a lighter version of the L.A.M.P. stack to acheave the exact same thing only this will run faster and allow your Beaglebone Black to run other things as well such as accessing sensors threw the headers so you can log them to the database and even display them with the web server across your network. Basically you are once again limited, limited to your imagination as what you will create using this L.L.S.P. server on your Beaglebone Black.
For this Guide you will need to be running Ubuntu on your Beaglebone Black, if your not already, here is a Guide on how to install the latest Ubuntu image. Install Ubuntu Server 18.04 on BeagleBone Black as well as setting up your user account. Create New User in Ubuntu on BeagleBone Black
1.) Check Updates.
it is important that your system is up to date so you can install the needed packages.
sudo apt update && sudo apt upgrade
2.) Install Lighttpd
Installing Lighttpd is simple as it is included in the software repo.
sudo apt install lighttpd
3.) Edit Lighttpd.conf file.
we need to make a few changes to the config file for Lighttpd in order for it to work with PHP which will be installed later on.
sudo nano /etc/lighttpd/lighttpd.conf
Edit 1.) In the server.modules section we need to add two lines. mod_accesslog and mod_fastcgi
server.modules = (
“mod_access”,
“mod_accesslog”,
“mod_alias”,
“mod_compress”,
“mod_redirect”,
“mod_fastcgi”,
)Edit 2.) Below compress.filetype we need to add the fastcgi information for PHP
fastcgi.server = ( “.php” =>
( “localhost” =>
(
“socket” => “/var/run/lighttpd/php-fastcgi.socket”,
“bin-path” => “/usr/bin/php-cgi”
)
)
)
Save and Exit nano (ctrl+o) save (Ctrl_x) close
4.) Install PHP
Now we can install PHP and the needed library’s for Sqlite3
sudo apt install php-cli php-cgi php-sqlite3
5.) Enable Sqlite3 extension in PHP.
In order for PHP to work with Sqlite3 we must first enable the extension located in the php.ini file.
sudo nano /etc/php/7.2/cli/php.ini
Edit 1.) Search by pressing (ctrl+w) then type in extension=sqlite3 , then you can remove the leading semicolon to enable it, save (ctrl+o) exit (ctrl+x).
…
;extension=sockets
extension=sqlite3
;extension=tidy
…
6.) Set Permissions.
Now in order for you to access the root web directory located at /var/www/html without using sudo every time you need to do a few things first.
Add your user to the www-data Group
sudo usermod -a -G www-data <yourusernamehere>
Set Owner and Group of the web root directory
sudo chown -R <yourusernamehere>:www-data /var/www/html
7.) Restart Lighttpd.
we must restart Lighttpd in order for all the changes to take effect.
sudo service lighttpd restart
8.) Test PHP.
Lets make sure PHP is installed correctly and working with Lighttpd.
sudo nano /var/www/html/test.php
Edit.1) add the below line and then save (ctrl+o) and exit (ctrl+x) nano.
<?php phpinfo(); ?>
9.) Open Browser.
Now type in the IP for your Beaglebone Black followd by “/test.php” and you should see something similar to this.
10.) Install Splite3
Last but not least we can install Splite3, this will install the text-mode utility for accessing databases from the terminal
sudo apt install sqlite3
Congratulations! you now have a working L.L.S.P. server setup on your Beaglebone Black, enjoy and happy coding…
Please tell me about your experience when setting this up and let me know how you liked this post by leaving a comment below
Thank you.