As you may have gethered, this site is running on a Raspberry Pi 3. The O/S is a standard Rasperian Jessie distro, with Apache2, MySql, PHP providing the Web Service and Citadel the Email service. And you what it is ‘almost’ brilliant. I will come on to the ‘Almost’ part in a moment, but first lets concentrate of the Brilliant part.
The Rapsberry Pi 3 is a doddle to set-up. There is massive support for this little device out there, with active forums, and lots of good open-source applications to gfet your teeth into. Solutions to most problems is usually just a DuckDuckGo query away, and when that doesn’t work a quick Sojourn to StackOverflow will usually result in a response within a few minutes.
I have my Raspberry Pi running headless (VNC to log-on and WinSCP for file transfer) with storage provided by a 64GByte SD card. Result is an acceptable (at least for me) Web and Email server running 24/7 and consuming almost no power. I can back up in a matter of minutes, and whilst I do try to minimise the risk of the site being hacked, should the worst happen, all I have to is re-write the SD card from back-up.
The Almost bit. Well I have maybe a little bit too ambious. I had originally constructed my Web Site myself. Implementing a rudimentary CMS (Content Management System). However I then decided that I would like to start a Blog, and rather than try to re-invent all the functionality that goes with good blogging software, I would use WordPress. My first implementation worked fine, but the two aspects of the site were not intergrated. Basically I created directory called ‘Blog’ under my Web-Site and installed WordPress in ‘Blog’. It worked, but it looked as you would expect, like two different systems.
I then started to fully integrate my Web Site with the WordPress site. In addition, being a good citizen, I switched to HTTPS (not that there is anything that needs encrypting on this site) . The result: My site is now fully integrated with WordPress. It is much easier to manage than it would have been I have perservered with my own system, and it looks and feels like asingle Web Site. But it is slow. I am now pushing the poor old Raspberry Pi to its CPU limits.
Good news? Well I am sure a Raspberry Pi 4 will be along soon to solve the problem. 🙂
The other good news is that by investigating WordPress and how it implements PHP and CCS3 Sheets I have a learnt a great deal about both topics, which means I should be able to optimize a great deal and get the performance back up, because I am keeping faith with my little Raspberry Pi.
As a Server
I have been using the Raspberry Pi for my server now for about four years. (Basically since the release of the Pi 2). initially there were rfeliability issues, in that the system (Raspian, Apache, MySql) would need restarting on a fairly regular basis (at least once every three weeks). These days however it is far more reliable, in the last nine months I have only experienced one none scheduled down time. Admittedly I have been doing more with the sever, which means I have been executing restarts and reconfigurations, but even so it does seem a pretty stable set-up. (At least for less than Â£100 it does.)
Immediately that the server went live, it was attacked. It is behind a fiewwall, but, of course, as a Web and Email Server it has a number of open ports. I have taken all the usual precautions re: usernames and passwords and have also configured Fail2Ban to monitor and annoy anyone trying to get into the system. A big thank you to the Fail2Ban guys, and I would highly recommend anyone who is using their Pi as an internet server to install this piece of software.
The server is also running on its own internal network (basically a DMZ), so should some one succeed in breaking through, they would not be able to (immeddiately) access any of my other PCs.
Well as I mentioned above the Pi 4 has arrived. It is suppoosedly 2 to 4 times faster than the Pi 3. Mine has just arrive, so lets get it configured, and running the Web Site to find out.
Unfortunately my Pi 4 would not boot. Checked online for possible issues. The recommended boot process from PiHut was:
- Latest NOOBS (Which was 3.1.1 at the time)
- Use HDMI Port 0
- Use Raspberry Pi 4 power supply
which is exactly what I was doing. Green LED blinked but no HDMI output. I even tried the S-Video out, and an LED Touch screen that I have that plugs into the display connector, in case the problem was with the HDMI cable. All to no effect. I tried the SD card in a spare Pi 3 that I have, and it worked fine.
I emailed PiHut support with all the above details, and I have to say that there response was less than stellar. Their inital response was astandard email that they obvioulsy send out each time, which says:
- Use the latest NOOBS
- Ensure you are connected to HDMI port 0
- Use a power supply that can supply 5.1V 3A, as the Pi 4 needs more juice than the 3.
Which is precisely what I detailed in my email to them. They have now agreed to a return and replacement. What this does give me the opportunity to do is to configure the spare Pi 3 from scratch and document the same.
Initial Set-up Steps
- On PC
- Formatted SD card using ‘SD Card Formatter’
- Downloaded NOOBS3.1.1.zip
- Unziped and copied contents to SD card
- On Raspberry Pi
- Plugged in Screen to HDMI
- Plugged in Keyboard and Mouse remote USB dongle
- Inserted SD card
- Connected Power
System booted fine, and presented screen that enabled me to connect to WiFi and install Rasperian. Installation of Rasperian requests
- Password for user Pi
- Location, and Keyboard layout
- sudo adduser xxxx
- Password – followed by the following optional prompts
- Room Number
- Work Phone
- Home Phone
- Is the information correct (Y/N)
- Password – followed by the following optional prompts
- sudo usermod -aG sudo <name> – to give new user sudo privileges
- Logout and login as new user. Test sudo privileges (eg sudo visudo)
- groups pi – to get list of groups that pi is in
- sudo usermod -aG <group> <user> to add new user to same set of groups. That basically makes me == Pi.
- sudo cp /boot/config.txt /boot/config.txt.backup
- sudo nano /boot/config.txt to get full use of screen.
- Left and Right values -10
- Top and Bottom values -12
- sudo apt-get install codeblocks – to Install CodeBlocks IDE. This also adds CodeBlocks to the programming menu.
- Select medium sized ICONs for top menu
- Select font Sans and size 10 for text.
- Started CodeBlocks
- New Project>Console App>Hello World in /home/<user>/projects (After I had created projects dir)
- Compiler settings >Warnings
- Treat as errors warnings demand by strict ISO C++
- Enable all common compiler warnings
- Enable Effective C++ warnings
- Enable extra compiler warnings
- Keyboard was not correctly configured. Backslash key was beinginterpreted as ‘>’. Not good when trying to program in C++.
- sudo raspi-config
- select correct keyboard and language. Yea, right. Forget that. Result was complete gobbly-gook from keyboard. Thought at one point I would have to restart the whole installation process again. Luckily, and was was only by luck, I did eventually choose
- Generic 105 Keyboard (even though I have a 107 keyboard)
- Language English (US) (Could not find an English (UK!)
- Location UK
If, like me you have gone for the fastest, largest SD card (at a reasonable price) that you can get, for me that is a 256Gbyte V30, then you need to be aware of a slight issue. These cards are SDXC and the SDXC spec states that they should be formatted as exFAT, which, by default on Windows, they will be. The Raspberry Pi will not work with exFAT partitions, it needs FAT32. To get round this you can format the card on a MAC, which will default to FAT32 or download guiformat.exe on your Windows PC.