Pi to the rescue...
While I was at it, I added a few extras, since a pi model 2 is pretty much loafing in this job.
The pi's camera, often handy - this one will be mounted under my eave for a perfect one-way glass so I can see the UPS guy coming and so on - probably get some time-lapse and game pix too.
PHPBB - the same software as used here, why not? It has a lot of uses. While a friend wants me to adopt a configuration management system, PHPBB does all that and more - since it's not web-facing, I set it up to allow any number of any kind of uploads, unlike here, and so as I do things I can keep track of them on threads, with the all-important "what was I thinking" as the text of a post that also has the software uploaded to it. And so on - other things like shopping lists, recipes and general notes on how things work around here, stuff most of you wouldn't be interested in, but I still need it to function with minimum effort.
Of course, this requires "little details" like a web server, in this case NGINX, and Mysql, for which I also added phpmyadmin. I have no idea what I'll wind up doing with this "spare box" on the LAN, someday.
I used vncserver so I can run it headless with a GUI - that'll spoil you fast.
So, I set this pi up with the Hackaday hardware hack (remove r4 and r50 and replace r with a 10k to get full 2 amps out of the USB jacks). I needed that as I'm running a pretty big disk drive off a SATA<>USB cable, and for grins, I also have an arduino uno on there (actually, it's Ada's metro, but basically the same thing) - they seem to come in handy. To make sure I had that power reliably, I used a cheap "simple switcher" I got 10 of from China on ebay for $13.80 - including shipping, and a wall wart. I may later add a gel cel for a ups, and switch down from that instead.
Here's the build - it's going into a cabinet in the wall of my living room, so it doesn't have to be purty: To make this extra-cool and super-maintainable and hopefully more reliable, I did a fairly cool hack that uses that 2 terabyte drive mounted over root - in other words, the SD card is used only at boot, for the UEFI partition at this point.
Even with a mere 5400 rpm laptop drive - it boots faster now than it did off an "extreme" SD card.
This requires a couple tricks. Normally /etc/fstab is used to tell the linux what to mount where. And that matters - so I changed it on this pi. But that's not all - root is special and defined also in the cmdline.txt file in the UEFI partition that's going to be mounted over /boot - and they have to match or this trick won't work.
Here they are for my case:
Code: Select all
proc /proc proc defaults 0 0
/dev/mmcblk0p1 /boot vfat defaults 0 2
#/dev/mmcblk0p2 / ext4 defaults,noatime 0 1
/dev/sda1 / ext4 defaults,noatime 0 1
# a swapfile is not a swap partition, no line here
# use dphys-swapfile swap[on|off] for that
//192.168.1.240/mnt/ /home/pi/amped cifs guest,uid=1000 0 0
/boot/cmdline.txt now looks like this:
Code: Select all
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/sda1 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
This isn't so hard if you do it at the right time.
cd /
sudo cp -rp * /dev/sda1
gets it done.
So, you edit those two files, do that copy (might take awhile) and then reboot - shazam, a pi with 2 terabytes of disk! If you want to be sure it worked, you can then surf to /media, where you should see the old /dev/mmcblk0p2 content - that's where linux puts things it found that have no instructions in /etc/fstab or /boot/cmdline.txt where to mount. If it's not under /media - it's not using the big drive, you have to troubleshoot things.
I had no troubles with mysql or phpmyadmin. NGINX has various issues, which are documented elsewhere on the board here. There's an excellent video tutorial that's a little out of date, and other posts on that thread document what you have to do differently to make it really work . NGINX, once working, is almost certainly the best web server one can use on a pi (if not everything). Mine is doing perl cgi's, php, and all through fast-cgi, so it really sings. PHPBB is faster here from a pi than this website is...go figure.
RPi_Cam_Web_Interface...well, this has a few issues. The author assumes you are a complete noob (perhaps not a totally bad assumption) but gives you no way to put this on top of an existing web server - it will install your choice whether it's there are not already, wipe things out, mess up the configuration files (makes a link to your old sites-available/default but erases the actual file!) - he got ahead of himself trying to look slick with shell scripting and sed?
It is, however some useful stuff once you get over it wiping out your NGINX install and tweaks. I suggest you either put this in first, or backup all your stuff first, and don't use /var/www/html for your own stuff, because it's gonna get wiped out - I put the rest of my stuff at /var/www and let the camera have the /html subdir of that for itself.
To get phpmyadmin and phpbb working, one creates a symbolic link to their "home" and places the link in whatever your web root is. You can then put a link to it in your index.html (or whatever you use for your main home page).
I also added some noob-user type stuff to upload and download files from the subdir I provide for that. There are a few different ways to get to it - you can also mount it directly over someplace on your PC (if you're using the superior linux, anyway) and just use it like any other space - but one that you can only access at around 12 megabytes/second - which is fine for what I use it for.
Before I finish, here's a couple of useful links. Nothing beats the video tutorial on NGINX, plus notes, but this is a good start and helps explain - including some of the other stuff:
https://www.digitalocean.com/community/ ... n-debian-7
This one shows phymyadmin and how to make that symbolic link that makes it all work automagically:
https://www.digitalocean.com/community/ ... emp-server
I used the same trick (with different names, obviously) to link to phpbb.
Here's what my web stuff looks like on the pi - and I didn't even have to disturb the cat on my lap to go over there - I got this shot via vncviewer, as the pi is running headless anyway: And here is some of the content. Since this is in use already, I don't include things like the uploads directory (huge), PHPBB stuff (you can download a fresh one, my content is my business) and so on. Just the cool stuff: And the simple cgi's I'm using for test and file uploading. If someone asks, I'll get to uploading the NGINX configs. The only trick not already documented here (somewhere?) is the use of the autoindex in a location directive in an NGINX config to allow browsers to get an FTP like listing of the uploads directory without my having to write any code but that.
This is pretty cool...I haven't used the arduino for anything yet, but if I have enough trouble getting the pi to control the pan-tilt stuff for the camera, well, I already have an arduino sketch for that...who knows, maybe I'll add some other data aq to it.
This doesn't look impressive - I don't care. It does a very worthwhile job, no ifs, ands or buts. You don't look at the home page - you go do things with this, right?