Showing posts with label Raspberry Pi. Show all posts
Showing posts with label Raspberry Pi. Show all posts

Saturday, 6 December 2014

Up and Away - Setting up a LAMPi

Acknowledgements:
For guidance I found a great article by Etel Sverdlov on Digital Ocean. Written for Ubuntu 12.04 - but none the less still valid
https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu

Installing a LAMP (server) on your Raspberry Pi

This is something that I have done a number of times now, but I've always dashed in and just done it in whatever order worked. Having looked at this in a bit more of a planned manner, I read Etel Sverdlov's article first, and that made a lot of sense. What I'm attempting to present here is based upon that, but with a few updates to call out some important points.

Step 1 - Latest repositories
First of all, need to update the repositories for aptitude (I prefer aptitude to apt-get - use apt-get if you wish)

sudo aptitude update


Step 2 - Install Apache2
Apache2 is a nice web server. Get used to it and it can be really friendly to use and administer. To install:

sudo aptitude install apache2

It's pretty straight forward. You'll be asked to confirm the installation of new files - just answer 'y'. Once that is done, then it is time to test your Apache2 installation using your browser. If you are running the Pi GUI on your RasPi, point your browser at 127.0.0.1. If like me, you are setting up your RasPi to be a headless server, with only the command line interface, you'll have to point another machine on your network at the RasPi's address. You should see a web page like this:





IMPORTANT!
During the Apache2 installation, there was one message - "Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName". This possibly happened on your install too. Depending on what you want to do with your RasPi, this may need to be addressed later on. For now, I'm letting it slide. Let's call it a Priority 2 TODO

Now you may have read my previous post, where I setup multiple IP addresses on the RasPi NIC at eth0 through aliases. So when I point my browser at the root address of the alias, I still get Apache's default index page. So, the web server is running, on both aliases. This is a bit more urgent - let's say a Priority 1 TODO.

I'll come back to these points in future posts. Moving on for now.

Step 3 - Install MySQL
MySQL is quite a nice bit of kit. Haven't used it enough. And full credit to Etel, I've followed her instructions quite closely this time. In the past I was quite nervous about attempting an install without the test DB, and without other features, but as Etel rightly point's out, these aren't necessary, and fixing them now will lead to a tighter installation, better for security. Keeping in mind that this RasPi is due to be effectively a production level machine, that's what we need.

Installing MySQL is a bit more involved, with a few choices to be made. To kick off the process:

sudo aptitude install mysql-server libapache2-mod-auth-mysql php5-mysql

From this command, your system may detect some conflicts in the packages, particularly apache2-mpm-prefork vs apache2-mpm-worker. Where we go from here depends upon what you want to do with your box.

For mine, I'm going to accept removing apache2-mpm-worker module. The apache2-mpm-worker is a more memory efficient module for handling multiple calls using thread processing. However it constrains then that you should only use thread safe calls, and this module is known to have issues with PHP. If we were building a dedicated MySQL box, without the Apache and PHP components, for a large, highly scalable commercial system, I would probably recommend differently. But for a low volume server, where system performance is non-critical, where some code used may not be thread-safe, I am choosing apache2-mpm-prefork.

Set the MySQL Root password when prompted. Just get it done and dusted. You can do it later, but doing it now will help avoid forgetting later.

Next, set-up and configure the database with the following commands:

sudo mysql_install_db

sudo /usr/bin/mysql_secure_installation


The system should prompt you for the MySQL Root password:

Enter current password for root (enter for none):

OK, successfully used password, moving on...


Now come the important security choices in the MySQL installation. The first will be the choice to remove anonymous users. For me, this is a no-brainer. Unless you want to setup a publicly accessible free-to-play database server, there is no reason. To support a web server, your install should only have known users with roughly three levels of access; root for admin, developer accounts for developing (or deploying/troubleshooting), and web app/service accounts for the applications that are going to consume the database. So, that's a yes to removing anonymous users.

Remove anonymous users? [Y/n] y
... Success!


Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
... Success!


HOLD THE FORT! Don't let root login remotely? How will we administer this? Don't stress, before putting the RasPi to it's final config, we will create the other user accounts. If however, you are already running your RasPi through SSH, you may wish to choose 'n' for this option for now. (Just note down for later that you need to change it)

Removing the default test database is another no-brainer. For this to be a production level box, we should not have any test artifacts. If this was for a development server, or a classroom education server, I'd say keep it, but for this one, it's going.

Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!


Reloading the privilege tables will ensure that all changes made so far will take effect immediately.

Reload privilege tables now? [Y/n] y
... Success!


Step 4 - Install PHP
Installing PHP is pretty straight forward, but there will be some more choices to be made along the way. Let's start with:

sudo aptitude install php5 libapache2-mod-php5 php5-mcrypt

Then as the chosen packages are identified, we have another choice to make, a conflict between libapache2-mod-php5filter and libapache2-mod-php5. "What's the difference?" you ask - well here goes:
  • libapache2-mod-php5filter is not thread safe, so if you opted for apache2-mpm-worker in MySQL (see above), do not use libapache2-mod-php5filter
  • libapache2-mod-php5filter does not pass PUT and OPTIONS calls to the PHP processor - sends them straight to Apache and can break WebDAV - possibly not good for collaboration platforms

So, with this reasoning together, my selection was easy - libapache2-mod-php5 stays.

Next we want to make sure that if we have a PHP coded index page for a site, that it will get recognised as the index page. This may, or may not have been put into the dir.conf file during installation. Double check by using sudo to open dir.conf in your preferred editor.

sudo nano /etc/apache2/mods-enabled/dir.conf

If necessary add index.php to the beginning of index files. The page should now look like this:

<IfModule mod_dir.c>

   DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm

</IfModule>


Check!

Next, you may want to add some extra modules to extend the PHP functionality. This does not need to be done right now, but if you want to, check which modules are available in the repositories first:

apt-cache search php5-

Choose your modules and install. Finally test the PHP install. Use your preferred text editor to create the following file: /var/www/info.php

<?php
phpinfo();
?>


Then restart Apache

sudo service apache2 restart

Now test the page in your browser: 127.0.0.1/info.php
If you see a page like the one below, all has been successful.

Thursday, 4 December 2014

Change Brings Challenges

For some time now I've been running a #RasPi off our router, providing the private cloud based options for file-sharing, collaboration, and getting to those important documents we forgot to bring. So far I'm very happy with ownCloud. I'm also happy with Apache as my base web server, though I have not done enough with it. A basic home page is all really.

Plus, that image has been up and running now for some time. It's image base is old (2013??) and it probably needs a spruce-up of its firm-ware. I want to put an email server on it. So far I'm considering Citadel as my front runner there.

The other problem is that I fear it may have been hacked. Either that, or with my increasing age, and the extended periods of time since I last accessed that box, I have forgotten the passwords. Ooopps! Can't have a box that has been rooted. The kid in me smells a counter hack in the making. The old bloke recognises that there was nothing on the box of any grand importance. A #rebuild with a new SD card and properly implemented security would probably avoid the potential of reclaiming a box with unknown backdoors.

Beyond this, what I'd also like is to setup the opportunity for some web services that can interface with some home-made mobile apps.

What I am uncomfortable with is our router. Yes, you can set it up to forward connections for different services and applications. It will forward incoming common protocols to the correct port on a specified IP address. I am not certain however, if you have more than one website, differentiated by port, that the router's port forwarding works that well. The interface for setting up the port forwarding is not user friendly. So, I am considering using multiple IP addresses on eth0 (#aliases), to ease the pain.

To set up for using multiple IP addresses, there are two methods. One is to a running change that is non-persistent An example of this can be found at Penguin Tutor. The method I am going to use will persist the changes when the RasPi is rebooted:

pi@exampleberry ~ $ sudo vi /etc/network/interfaces

Edit the interfaces file with vi to add the eth0:0 alias

iface eth0 inet static
  address 192.168.72.88
  netmask 255.255.255.0
  gateway 192.168.72.254
  auto eth0

iface eth0:0 inet static
  address 192.168.72.89
  netmask 255.255.255.0
  auto eth0:0

...

iface eth0:9 inet static
  address 192.168.72.98
  netmask 255.255.255.0
  gateway 192.168.72.254

Repeat as necessary for aliases eth0:1.. to eth0:x, depending upon how many aliases your box requires. Save the changes to your interfaces file and restart your network services.

pi@exampleberry ~ $ sudo /etc/init.d/networking restart

Check the results by running ifconfig.

Of course, a potential headache that I will create by doing this is that I will simply increase the exposure of my RasPi box to further intrusions. So before I go any further, its time to research how to harden my RasPi and monitor for intrusion.


Acknowledgments: Narad Shrestha's article on Tecmint (http://www.tecmint.com/create-multiple-ip-addresses-to-one-single-network-interface/), "Create Multiple IP Addresses to One Single Network Interface"

Tuesday, 31 December 2013

My ideas have been QNAP'd

It has been some considerable time since my last post. Whilst my fingers may not have been typing as much, this does not mean that productive work has ceased. Far from it. I have in recent months encountered a number of options and ideas that will change the scope of my work with the Raspberry Pi.

Within my own home environment, I have been seeking to utilise the RasPi as a solution for a number of different needs; home automation, media centre, games console, personal cloud server, web server, print server, etc. Up front the RasPi has three core strengths from my humble opinion; ease of use, low-cost and energy efficiency at 36W. However, it has some drawbacks as well.

With respect to it's use as a media server, the software solution that I had heard a lot about and had been wanting to use (because it was the one that would work with our main TV) was Plex. However, Plex is not available on the RasPi. With any server that is storing large amounts of data, that is constantly running, having some kind of redundancy in the storage. Let's face it, the time taken to rip several hundred DVD's and CDs to a media server, and the bandwidth required to download others is not insignificant, and if you've done it once, you really don't want to go through it again. Unfortunately, with only USB connections for mass storage options, the RasPi is limited in this aspect, and the more hard drives that you have plug in through a powered hub, or with their own power supply, the less green the RasPi becomes as an option.

Over the last month I have had good fortune to spend some time with fellow geeks who have sorted their home media centres and are using Plex. I've been lucky to receive demonstrations of their systems, and more importantly one of them revealed that he is running his system from a QNAP server. I asked about power consumption and he told me that since replacing an old PC with the QNAP server, their power bills had decreased about $100 (AUD) a year. Given that the QNAP servers have multiple drive bays, mounting multiple hard drives and configuring a RAID array will provide redundancy. They have multiple Gigabit Ethernet ports, half-a dozen USB ports and other features too. What's more, they only draw 40W when in operation (less for sleep mode) and their processors are far more powerful than that of the RasPi.

Awesome!

So, does this mean the end of the Rastaberrian Project? Hell, no! It just simply means that I can refine the scope of my ideas of what to do with the RasPi, and remove the concept of using it as a media, print or personal cloud server. My current thoughts are to place any such server in DMZ, so that it can be accessible externally as well. In considering the RasPi for home automation, my current thoughts are that this should be secured within the home green zone, and if external access is required - facilitated by web services via a secure web page hosted from the DMZ. Use of the RasPi as a games console, or to make an ordinary TV into a Smart TV, I think still holds merit.

Friday, 20 September 2013

RasPi and a 13 Port Hub: What Would You Do?

My recent acquisition of a 13 port hub to work with my Raspberry Pi got me to thinking, what could be done with it?

Sure, I'm intending to work with it to develop some energy and cost efficient #media_centre options, but my mind has been ticking over what other options it could be used for - with the two devices combined, that provides a total of 14 USB ports. With the combination of an #Arduino kit or two, it could be rigged up with motion sensors, then when activity is detected by the Arduino sensor nodes, it could wake up a number of web cams to record the activity. Possibly useful as security for a small office or apartment. You could have an array of 4 +Arduino sensor suites, and 7 web cams attached. The remaining two ports (remember the Pi is drawing its power from one port) could be used for an external HDD to save the footage to, and a wireless Broadband modem - so that when activity is detected it can contact you and provide footage on demand.

So, I am looking for some inventive ideas please.

I'll kick off the party with my own idea - this one is less serious and more fun.

1. The Venus Pi Trap
Requires;
3 x Arduino controlled sensor arrays - each array has motion and distance sensors
1 x Raspberry Pi
1 x 13 port hub
10 x USB missile launchers

Write a customised app for controlling the sensor arrays and the missile launchers. The app interprets the motion and distance data from the sensors to triangulate on the motion, and in turn aim the USB missile launchers, then fire. Surprise your family and friends! Slaughter your siblings in a hail of rubber missiles! Teach the cat that the corner of the room is not its litter tray! If you think a battery of 10 missile launchers is overkill, just replace one or two of the launchers with web cams - capture the carnage forever. Shock and Awe!.

Thursday, 19 September 2013

Play Room Media Centre: Green Hub Option 2

Given that it's not possible to get the PiHub in Australia yet, I've been looking out for other options. Particularly option that would draw the same or less than the PiHub, yet still offer the same functional advantages.

I Was Bad
Yes I found an option to the PiHub, and I bought it. Thank you Dick Smith for the XH1237 powered USB hub. This beauty draws 108W through it's power pack. That's about the same as three of my Raspberry Pi machines. But it did cost $60 AUD. That is a fair bit more than the PiHub. Ooops!

But Wait There's More...
The real beauty of this device though is that the output of its power pack is 5VDC at 4A. That means that whilst the power pack draws the power of 3 RPi, it puts out enough to power 4 RPi. And it could power 4 RPi and have ports remaining for peripherals. Yes, you heard correct. This baby has 13 USB 2.0 ports!

13 Ports? Really?
Yep. Now you might well be thinking that this is a bad case of over-kill. It could be. But, lets think in terms of a Media Centre that has the capacity to play games. Now of course you are going to want the hub to power the RPi. You are also going to want to plug in a substantial size HDD and a WiFi dongle. That's 3 ports gone. Wireless keyboard/mouse dongle. That's 4 ports gone, with still room to spare. So let's assume you want a second HDD in there - the first was for your movie collection, then second is for your games. Sweet. Now lets throw in some neat gadgets for your gaming experience. Say a steering wheel, pedals and feedback chair. We've allocated 8 ports now. There's 5 ports spare on the hub, plus one other on the RPi itself.

What More Can We Plug In?
Now depending upon what games you have and how big your screen is, it could be feasible to have up to 4 controllers plugged in. We could also plug in a web cam. Bam! That's our 13 ports filled, but look at what we've achieved - neat!

Thursday, 12 September 2013

Play Room Media Centre: Hail the PiHub!!

In my previous post regards the development of a play room media centre, I cited one of the key goals was to attempt to build a solution that was going to be more green than other games/media centres on the market - and trying to keep the power consumption as low as possible.

Now there might just be something to help gain that all needed advantage, thanks to the pirate crew at PiMoroni - all hail the PiHub.  When I saw the post pop up about this earlier tonight, I was all set to go and buy one, damn the torpedoes!  Problem; they seem to be shipping with power packs for the UK and EU market.  Any chance that they could do one for the Australian market?

The Drawing Board
Looks like this post is therefore relegated to the drawing board.  So what was all my excitement about?  Given that I am still at the research and planning phase of my media centre project, I don't need to rush out and get a PiHub right this minute.  Well the PiHub is a powered four port USB hub built with the Raspberry Pi specifically in mind.  As you may recall from my previous post, my initial plans for a media centre incorporate USB keyboard, USB mouse, USB WiFi dongle, and USB HDD.  So that's four USB devices.  Now, if we configure the +RasberryPi so that it is drawing power from the PiHub, that means that we have just enough USB ports left on the Pi itself and the hub to cater to the four peripherals.  Great - that should then be quite tidy.

Shooting from the Hip
What we do know about the PiHub is that it's power pack supplies it with 3000mA (3A) of power.  My current Raspberry Pi power pack only supplies 1A, and consumes 36 W.  What I have not been able to discover yet is, how much power does the PiHub power pack consume?  For now, I am going to shoot from the hip and assume that since it's output is 3 times the amps of the Rasberry Pi power pack, its consumption is also 3 times greater.

If this assumption holds true, that means that the media centre project project built around a PiHub, would consume approximately 108W.  Based upon my initial research of the current media centre market makes it competitive.

From Here...
From here I need two things; to confirm the power consumption of the PiHub power pack, and to seek another edge to make my idea a worthy opponent of the current market products.

Monday, 26 August 2013

Play Room Media Centre: Keeping Ahead of the Curve

Following on from my last post, with any ideas of what we could do with a RaspberryPi in the #play_area, I need to make sure that I have some of the questions and answers squared away before introducing the ideas to my son. He's a smart, intelligent boy, with a great ability to conceivewhat could be done. But like all seven year olds, they don't necessarily handle failure and changes to plans once you start them on something. So, with any such projects, there is always going to be the necessary parental home work to be done upfront.

Play Room Functions
There are a number of needs that could be fulfilled within our son's play area. He loves watching his DVD/Video collection (my wife has an uncanny knack of finding old kids favourite videos in good condition!). He is also at an age where his musical tastes have and will continue to expand beyond the Wiggles, so playing music is also required. As all of these media can be digitised and served across our network - this all comes under the need for Wi-Fi media streaming. Though for the sake of our household Wi-Fi performance, it might be best if the majority of the children's content is available locally on the media centre.

Some of the programming that our son enjoys may be available from online/smart TV services line the ABC's iView service. However, other programs are not. Our experience is also that some smart TV devices are not compatible with the ABC's iView. So being able to watch free-to-air digital TV is desirable, but at the moment, we'll consider what hardware will be required to provision this, but not move to implement.
Games console. Don't ask how, but somehow we have existed all these years without owning a games console. No Xbox, no PS3, and no Wii. No we are not deprived and nor is our son. If anything there are times when he plays too many games already. However, as part of having a play room that provides entertainment to a small group of children when he has friends over, having a multi-controller games console would be good. Lets face it, having a group of friends huddled around one PC and a small monitor in the confines of a bedroom, whilst cosy, gets boring for those who are waiting to have a turn.

Other Requirements
All this needs to be established in such a way that it's power usage is economical, and such that it does not cost a lot - which might mean some seemingly crazy, yet innovative recycling/re-purposing of devices.

Initial Research - OS
One of the many questions to resolve here is which distro would be the most likely to achieve the greatest number of requirements - therefore providing a simpler low-risk solution and less set-up effort - and keep the focus upon conducting a successful project. Primarily I am considering one of two options - Debian 'Wheezy' and RaspBMC. Of these two offerings, RaspBMC is probably going to cover the need for the storage and streaming of digitised content. I am yet to find another distro for the Raspberry Pi that is know to be stable enough that would natively support a gaming interface such as Valve's Steam.

So, this is something that will need to be tested - is there a Raspberry Pi distro that can run steam? If not, this does not kill the project nor mean that we cannot meet the requirement. It just means that when we look for games to play, there will be a simple 'marketplace' to get them from.

Initial Research - Hardware
From the requirements that I've set, the solution is going to require the following hardware:

  1. Raspberry Pi - I'd like to go with the latest, but I have an old Rev A Ver 2 that needs to be put to use.
  2. Powered USB Hub - to power the Raspberry Pi and to provide device connectivity
  3. Wireless keyboard/mouse replacement - For the moment, I'll have to start with just a USB mouse and keyboard.
  4. USB HDD - at the moment I do have an HP 3TB unit sitting spare. I need to test it on the Pi as it is a little proprietary in its interface. It has it's own power supply which draws about 144W - so I am not entirely keen on this. A unit that is less power hungry or that could be powered through he USB hub would be nicer.
  5. USB Wi-Fi dongle. I have a Netgear Wireless N dongle that's been spare for a while. It might well be too old to support the bandwidth for the media streaming.

Initial Research - Power Consumption
What are we replacing? A DVD/Video player, in which the DVD does not work (50W), a DVD player (15W), and a stereo system that I suspect runs about 45W - but given that CD's can play in the DVD player, it's consideration is negligible. There is also the as yet non-existent games console. So for now, that means that we are trying to keep power input to around the 65W mark (drawn by existing DVD and Video players combined). In terms of considering the project a success in this aspect, some consideration must also be given for replacing the need for a dedicated game console. Not currently owning one means that more detailed research of their specifications is required.

If all that is required to successfully implement this was the Raspberry Pi, a Wi-Fi dongle, and a wireless RF or Bluetooth dongle to connect to a wireless controller, that could be successfully achieved on just the power supply for the Raspberry Pi, which draws 36W.

I know from previous investigations that most powered USB hubs draw more than 60W, and the powered USB drive I have sitting handy draws 144W.

From doing some leg work and looking for the power consumption specs for game consoles online - well they sort of do not exist. That is to say, that in conducting searches it was easier to find power consumption statistics from independent sites, than from the manufacturer's themselves. Probably the most useful statistics I found compared the Wii U, the Xbox 360S, and the PS3 against one another (http://www.eurogamer.net/articles/digitalfoundry-wii-u-is-the-green-console). Definitely the Wii U runs at 30-35W by this reckoning, where as the older versions of the Xbox and PlayStation platforms were running at 65-75W. Not sure about the power drain of the Xbox One and the PS4 - the companies are all about bragging about the power usage when in stand-by or low power modes, but not about their power consumption whilst the device is actively being used.

So to keep this home-made solution green, I think that a reasonable target for success is 100W or less. At 130W or less, I think it could be considered on a par with the collection of devices that it replaces, but any result over 130W would be a fail.

Sunday, 25 August 2013

Child's Play

I sometimes feel like I'm caught between two worlds. My father was one of the key people for getting Wang computers into parts of the Australian Federal Government, however his generation were born before our modern computers, and so he was always playing catch-up. My son at age seven has taken to having laptop and joining me in playing with the Arduino all to easily. And it has only been through my own lack of organisation that he hasn't had the opportunity to play with a RaspberryPi.

But we are taking steps in the right direction.

As an educator I know that even when dealing with an audience that has a background in the subject area and a strong conceptual ability, it is useful to have tangible, physical models to help stimulate and backup their learning of concepts. And this is where I think that the Arduino has a really strong place. There is just as much that can be done to demonstrate the base concepts behind electronics and programming by modifying the set-up of a circuit as there is to rewriting code, and this is an important point that the Arduino brings to any session of working with it.

When we gave our son my wife's old laptop, I first cleaned it up. It's about a 5 year old XP netbook. Even though he'd spent time on our desktops every now and then, it took him a while and some persistence, and many questions to get the swing of using it as a power user. And so his hunger for the knowledge grew. Apart form playing games, and researching old Dr Who episodes on YouTube, every second day he was changing his desktop appearance and demonstrating more skills in the administration of the machine.

Then he saw my Linux Mint-Cinnamon machine in use. He wondered what this Linux thing was and he wanted one – so now his laptop dual-boots. Interestingly enough, whilst he has made changes to the Linux Mint config, I haven't been consulted.

Being aware that he was yet to get the Raspberry Pi experience, I grabbed an idea from the Raspberry Pi distros, and installed Scratch on his Linux Mint partition. With a bit of coaxing he got into using it quite well. That was a couple of weeks prior to the both of us ending up on bed-rest with tonsillitis. With my wife overseas at the time, despite the fact that my son was sick – he still had his bounce. How would I keep him in one place, where it was warm, safe and preferably a bed, such that he'd recover quickly and if I fell asleep because of my illness, he'd still be right next to me? And that's where having Scratch tutorials on YouTube playing on the bedroom TV became a real godsend. By the afternoon of our second day laid up, he was re-mastering PacMan.

So I had been thinking about using a Raspberry Pi to make the play-room TV into a smart TV, and to give it games. I think the best course of action may be to let my son give that project some direction.

Wednesday, 5 June 2013

It's been a while since drinks. Time to return to the bar!

Apologies for this being a quite blog.

Having been busy with my regular job, and periods of re-occurring illness keeping me down, I have not had much chance to get into playing around with the +Raspberry Pi  .  Looking forward to that all changing.

Bought an +Arduino starter's kit a few weeks back.  Got it out the weekend before last and introduced my seven-year-old to it.  Soon had him getting into understanding the programming control structures - after a couple of projects he was happily adapting the sequence in one of the chasing light projects.

I thought that it would be relatively easy - didn't think it would be that easy.  Wow!

Saturday, 8 December 2012

Immediate Needs

Well it has been a while since I have had a serious play with my RPi machines. Part of the issue being our power bills – really wanting to bring those down, meant redesigning our home network. In the end I removed two big boxes, a router and a switch. Which should reduce our power consumption by a good 5kWh per day or more. But still the power bill and usage is high. It needs to come down for both the sake of the environment, and so I don't need a second job.

So with this in mind, I am going to turn my first two RPi boxes to two particularly dedicated causes. One being that of a web server for both internal and external facing sites, the second as a CUPS server.

Given that I have not decommissioned, nor do I currently run a web server, why would I do that? Is that not just creating another machine to run and draw power? Yes and No. Currently my wife and I have about 6 different 'sites' (blogs, sites etc) with freely hosted arrangements. As we expand upon what our Internet communications are doing for our professional lives, we will want to adapt our web sites, and this is likely to mean paying for web hosting. Why not run our own server, and with the money saved in hosting costs, cover a little more power usage?

The CUPS server is another no-brainer once I thought more about it. Whilst I have taken to shutting my desktop machine down at night/in the morning, I often come home to find that it is on. That's because my wife has been doing some printing, and it is my desktop that shares the printer to our home network. I think a CUPS server that can be on 24/7 might be more the go.

So with these two challenges in mind, I have set off to get it done.

Web server.
Where to start? Simple, lets do this the professional way and start with the requirements.
Web server capable of serving up a number of sites. Preferred server-side script is PHP. Preferred DB is MySQL. So a LAMP server it is then! With phpmyadmin too please!

Without too much trouble I did a quick search for blogs/posts about this and first hit I found was at www.instructables.com/id/Raspberry-Pi-Web-Server/. Good post by drcurzon, lots of screenshots and easy to follow, step-by-step instructions – hence I am not going to make a hash of it by trying to reinvent it.

The one change I found necessary was in Step 9. If in the /etc/passwd file you comment out the pi user line (assuming pi is the user that you wish to use for FTP) you will not be able to connect via FTP, nor start a new SSH session. So from my experience, do not comment out this line. Merely observe that the running of the command usermod -d /var/www pi does change the default folder to open.

The only other problem I had I caused for myself by forgetting the credentials that I set for phpmyadmin. Eventually found them by going:

sudo nano /etc/phpmyadmin/config-db.php

Now the next trick will be to put my RPi web server into my DMZ, and ensure that I can connect to it for SSH and FTP, and web of course.

Monday, 5 November 2012

Another Life

As someone with a bent for security, there are several 'rules' that I follow.  First is to avoid connecting an unsecured device to the Internet.  Another is to always change the factory default passwords to achieve the first rule.  The third is to never write a password down.  This often requires that I break rules one and two when I forget a password.

I did get my previous RPi install up and running under wheezy, with a wired USB keyboard and mouse.  No problems.  Even set the root password.  Forgot that too.

Opportunity.
So now that we have yet another edition of the Wheezy image to play with, I'll start again, with the following resources:

1 - Rpi Version 1 board inside a perspex case
1 - micro USB, 1A power supply
1 - HDMI -> DVI dongle
1 - 17" LCD monitor
1 - SanDisk 8GB 10 SD Card
1 - USB keyboard
1 - USB Mouse

For the software side, I have the latest "Wheezy" image
2012-10-28-wheezy-raspbian.img

Research and Lessons
So, what I have found out since the last attempt to fire up the RPi is:

overscan - this setting allow you to correct for boarders around the screen image on HD displays and for the correct centering of the screen.

memory_split - this config setting allows you to control how much of the RAM is dedicated to the GPU processing.  There are three possible settings: 32MiB, 64MiB and 128MiB.  64 meg is the default setting.  If you want faster graphics pump it up to 128 meg.

overclock - obvious what this config setting is for.  The options available are complex, and I am not going to pretend to know them all.  See RPi Config wiki for further details.

Outcomes
So far much the same as the previous occasion.  I tried running change_pass in the config - erred for some unexplained reason.  Selected en_AU ISO-8859-1 as my locale.  Went to the memory_split option - here the config gives 5 options, 16/32/64/128/256.  64 is the default, but I think I want 128, as I will test this build as a graphical user workstation for the home.  Overclock I will leave alone for now.  SSH, I will leave alone.  For now I will also leave the boot behaviour alone, as I want to be able to do admin from the command line at times.

After the reboot and login, have changed the password.  Now I'm running startx. What a clean interface - I like it.

Thursday, 18 October 2012

Current Theorems - Am I on Track?

Perhaps my previous calculations of power consumption are too simplistic.

In researching green options, I discovered on some forums the use of a 5 port USB powered hub to deliver power to the RPi, and its peripherals, with the RPi delivering communications and data back to the hub.  I had been wondering about the concept of using one hub to power multiple RPis - would it be more efficient and greener?

Both the RPi and the hub run from their own transformers.  The RPi transformer has an input of 240V at 50-60Hz, drawing 150mA, and delivers a DC output of 1A 5VA.  To my limited knowledge of the calculations involved, this means that the input power is: 240 x 0.15 = 36 Watts, and the output is: 5 x 1 = 5 Watts.  This would imply that 31 Watts is lost to the resistance and impedance of the unit, and generates heat in the transformer.

When I look at the input and output of the USB hub's transformer, the input is: 240V at 50-60Hz, drawing 1A, therefore 240 Watts.  The output is 5V 1.5 A, therefore 7.5 Watts.

This would imply that whilst the powered hub supplied 50% more power, it draws 660% more power from the mains, and hence would not be a greener more efficient supply.

However, I know that my knowledge in this area is presently limited - am I using the right calculations and making the right deductions? Should I be calculating and comparing the power consumption of the transformers from their input or output values? Are these constant loads, or the maximum loads of each unit?

Anyone able to help?

Sunday, 14 October 2012

Raspberry Pi - The Organic Way to a Green Network?

Epilogue to the Previous Post

There was life in my RPi, but not as I planned it Jim!

As a headless box, remotely operated through an SSH session, the Pi worked well - including its raspi-config tool.

But the wireless USB keyboard and mouse not working was my fault.  I didn't check the specs of the peripherals first.  If I had, I would have realised that they were not compatible with Linux.  Have since ordered a new set from Element14.

Going Green

Whilst waiting to get these goodies, I've been doing some thinking and planning.  My testing of the RPi and its abilities against other platforms is still in the planning process..  But in parallel I've had some other thoughts.


Looking at the power bills that we are getting out in a rural region - horrendous.  I'm certain that part of that excessive power usage is my small network of machines at home.  Yet I want to do more from home, with more machines.  That can only mean one thing - a bigger power bill.  Or does it?

Perhaps the RPi can come to the fore here.  Part of the problem is the machinery that I leave running most of the time.  My desktops and laptop are not so much of an issue if I shut them down overnight when not in use.  But looking at my network as it is now, and how I would like it to be, there are several spots in which I might wish to substitute in a RPi.  The list of appliances that I would like to have running 24/7 includes:

  • Firewall/Proxy Server
  • Dedicated Web Server
  • Dedicated Web App Server
  • Dedicated DB Server
  • Dedicated IDS/Honeypot
  • Dedicated Print Server

In considering the suitability of the RPi for any of these roles, I need to be able to compare apples to apples.  To do this from the power supply perspective, we need a way of comparing our traditional desktop power supply of 300 to 400 Watts, to the 1 Amp supply running the RPi.  To do this, we are going to make use of the equation;

          Watts = Amps x Volts

So, how many Watts does the RPi draw?  This is always going to be dependent upon the power pack used.  The power pack that I'm using currently has an output of 1 Amp at 5 VA.  But that is what it outputs to the RPi, not what it draws from the power socket.  What it draws from our power socket is 240 Volts at 150 milli-Amps.  Throwing these values into our equation;

          Watts = 0.15 x 240

          Watts = 36

But of course, I could compare this to a desktop or server with a 1KW PSU, and rave on about how much of a saving it should make, but it is not the size of the PSU that is important, but the amount of hardware that it supports.  From various sites you can utilise an online power calculator.  I went to eXtreme Outer Vision's calculator page.  Here I plugged in the values that were as close as possible to what my existing firewall machine has.  It is running a 300Watt PSU.  I calculated the power draw for it based upon a 90% CPU utilisation and it calculated that it would require a minimum of 198 Watts, but recommended 248 Watts to be sure.  For my comparison, I am going to take the conservative value of 198 Watts.  This is nearly 6 times more than the power draw of the RPi.  I think that there could be some real savings achieved.

To see how these potential solutions turn out, I have started a new page at: Raspberry Pi and Green Home Network

Tuesday, 9 October 2012

Is there life?

Many ideas have been swirling in my head of late, for this project.  However, they are all far into the future for now.  Right now, the key critical thing is to get one of my RPi boxes active with a standard generic OS.

So, lets recap what ingredients I am putting into this stock-standard mix.
1 - Rpi Version 1 board inside a perspex case
1 - micro USB, 1A power supply
1 - HDMI -> DVI dongle
1 - 17" LCD monitor
1 - SanDisk 8GB 10 SD Card
Medion cordless keyboard and mouse

For the software side, I have the latest "Wheezy" image
2012-09-18-wheezy-raspbian.img

Setting up the SD Card
This went rather smoothly.  Simply follow the instructions presented at RPi Easy SD Card Setup.

Plug it in and Go!
Next was the easy step of plugging everything in and letting rip.  Since there is no on/off switch for the RPi, it starts as soon as you plug the micro USB adapter in.  Very quick to start up.  in under 20 seconds, Wheezy has loaded, and has opened the Raspi-config screen.  One small problem here for me, the wireless keyboard and mouse are not supported.

There are essentially two options that I have at this point.  The first, is to find a spare USB keyboard and USB mouse and plug them in - not so easy at 9:30 pm at night.  I do have a spare PS2 keyboard, and a semi functional USB mouse, but I'd need an adapter dongle.  The second option (I think), if the RPi has loaded its OS enough that it can network and accept telnet commands is to network it, and remotely take control - though I'm not sure how this will go given the config screen it is currently displaying.

Why Not Remote From Word 'Go'?
Perhaps I am over cautious, but one rule I have is not to network something until you have secured it.  Out of the box, the wheezy image is not secure.  It's preset login account has its name and password posted to the Internet.  However, if I can network it and remotely login, I should be able to secure it with a password change, and passwd the root account in a reasonably short space of time.  So I will try that.

Apart from a bit of cable management - my routers and switches needed some switching around to fit my RPi into the subnet that I wanted it - this step was fairly simple.  Thank goodness for good old PuTTY!  Started an SSH session with the RPi, and was able to reset the pi user password, and the root user password.

Interesting to note, that in the PuTTY session it has shown the message "NOTICE: the software on this Raspberry Pi has not been fully configured. Please run 'sudo raspi-config'".  Excellent.  So that's the next step.



On running the config, you'll see a number of options.  The info screen is just a short paragraph that recommends using this config tool earlier rather than later - before making any major changes of your own to the set up.

'expand_rootfs' is an option that I'll explore later.  As noted in the RPi Easy SD Card Setup page, the standard image is only 2GB.  I'm running an 8GB SD Card - so there is spare space there.  The RPi Resize Flash Partitions page talks you through the options of expanding this existing partition, or creating a data partition.  For now, I'm going to leave this.

'overscan' is an option I have not heard of before.  When you enter the screen for it, there is simply the option to enable or disable.  I need to research this more.

'configure_keyboard' is an option I'd really like to fix - given my issues so far.  Upon entering this option, the screen reverts back to the command line for a few seconds to load the keymap.  It sets the preliminary keymap, and then returns to the config screen.

'change_pass' - already did that through the PuTTY session directly with the 'passwd' command.

'change_locale' is an interesting option.  Again, this will quickly leave the config screen to the command line to load some values, then brings up a new config screen.



For Australia, not sure what to pick on this screen so I will go with the advice of picking a UTF-8 locale code.  My selection leads to another config screen, which appears to indicate that I have selected a locale that has access to english_Great Britain character set.



Selecting OK here, then leads back to the command line, whilst the locales are generated.  When finished it will return you to the main config menu.

'change_timezone' - at the moment I need timezone Lima - UTC +11.  Lets see what's set.



First screen allows you to select the geographic area.  For those in Australia, simply scroll up this list to find it.  From there I'll select Canberra as the nearest city to where I live.



Done.

'memory_split' - I will investigate and get back to you.

'overclock' - I am interested in using this option as I have heard that the 700MHz CPU can clock up to 1GHz when performing particular operations.  For now, I'll leave it as stock standard.

'ssh' - This I suspect is as the menu describes, a toggle option for SSH server functionality.  Either enable or disable.  Given my current session was started under SSH, I'd say the server in the wheezy image is enabled by default.

'boot_behaviour' - this option gives you a vote to start straight to the desktop on boot - Yes or No.  For now, I'm going with No.



'update' - note the uncertainty of this option.  The menu description says 'Try to upgrade raspi-config'.  I suspect that from the description, this will not upgrade the kernel or any Linux modules, other than this very config module.

Back to the Books
So for now, there are some items for me to research and explore, and return to later.  So I'll finish with the config.  This leads to the option to reboot now, which I will.  Unfortunately, upon reboot, I am still in the state where I can not use the box on its own - I still need to configure the wireless keyboard and mouse.  Something more for me to research for the next post.