For some considerable time now I’ve been using Apache (web server) on my various SBCs to present a basic web page, run PHPLITEADMIN (local SLQLite Database Manager and do other menial jobs. A LONG time ago I got rid of MySQL (which I had used on and off along with MS SQL on larger machines for a long time) despite it’s undoubted qualities as MySQL tends to be not ideal for the likes of little Raspberry Pis with their limited resources and limited life SDs. Well, that was a start but now it is possibly time to move on from Apache to something a little lighter on it’s feet as well.
Antonio is busy having another so at setting up Caddy as an alternative web server, but he’s having a busy week and I could not help but give Nginx a go – I WILL play with both that and Caddy in the very bear future and the winner will no doubt get into “the script”. Any web server for me has to run PHP, preferably v7 as I like to be up to date – warning – I’ve only tested this on a Raspberry Pi 3 (2 will work) but as there was nothing specifically Raspbian-ish in the setup I’ve no doubt this would work elsewhere.
Nginx is a web server which can also be used as a reverse proxy, load balancer, mail proxy and HTTP cache. The software was created by Igor Sysoev and first publicly released in 2004. But for my needs, it is simply an easy to install and use, relatively lightweight web server.
After reading a small amount about Nginx, which apparently has a not insignificant share of the server market, I stumbled on this: https://howtoraspberrypi.com/install-nginx-raspbian-and-accelerate-your-raspberry-web-server/
Only a couple of things… following disabling Apache as recommended, I removed Apache with “sudo apt-get remove apache2” without the quotes of course and then “sudo apt-get autoremove”. That left some files in /etc/apache2 so I used “sudo rmdir –r /etc/apache2” but if you find all of that too permanent you could just leave Apache2 disabled – unless of course you don’t have it installed.
I followed the instructions above to the letter, stopping at the “Error 403” paragraph heading. Everything worked including my original PHPLITEADMIN and a simple html web page I had sitting there. The latter worked as you’d expect, the former only if I specified the index.php page by name. Well, that was no good so as ROOT I went into /etc/nginx/sites-available – therein is only a text file called default – which has a line showing acceptable default page names including index.html and index.htm – I added index.php to that.
All was perfect but I’m used to PI user (in WinSCP etc) being able to see the files in the /var/www/html folder – so I made a minor change to make permissions for /var/www the same recursively – i.e. 755 – you may or may not wish to copy that if you have security concerns.
Now I was cooking – all my favourite PHP stuff was working just as before along with my default.html home page but without the weight of Apache.
Installation and initial (trivial) testing went so smoothly that I thought I’d also see if I could push my luck and find a PHP alternative to PHPLITEADMIN. After doing the rounds of what is available, I stumbled on MyWebSQL – and it is lovely. It handles MySQL, SQLITE and POSTgreSQL and comes with wonderful themes. Installation could be done by a blind drunk monkey.
This page was helpful.
I took the mywebsql folder out of the zip file here and put it into /var/www/html – _ then edited the config/servers.php file therein to add a username and password and point the editor to my sqlite db directory (not to any particular file).
That’s IT – it ALL WORKS.
and if you don’t like the colours – see INTERFACE – THEME at the top.
If only all installations were THIS easy. As some of you know, after a life steeped in electronics and computer software, I’ve been doing a damn good job of keeping up to speed but late last year, at the ripe young age of 64, out of the blue, I had an ischemic stroke – and not a toy stroke either, but one of those cruel tricks of nature to teach me a lesson for getting good at what I do. I was out of commission for 3 months (in hospital) and although I’ve worked extremely hard to recover (and in the process, deliberately shed 30% of my body weight to help (as far as you can) ensure that was a one-off hit), getting my act back together has been (and continues to be) hard work, only in the last month have really got it together sufficiently to consider getting ambitious again with my home control kit. There is so much hard-to-follow (and often old and/or inaccurate) material out there that it came as a sheer delight to find material I could follow immediately without asking people lots of questions and in a matter of hours, not only install a working new web server and new SQLite manager on a Pi (I’m keeping PHPLiteAdmin as well – why not) but also document it in this blog. I am of course immensely grateful to those who have helped me get this far back into the driving seat.