..now hacking prize of nice hackday badge!
Now that your system is on, able to be controlled via VNC, it is time to install apache2 and MySQL, the webserver and the database.
This is really not difficult, the packages are so well known you can find a lot of guide on the web.
Largest part of this tutorial is taken quite as-is from here, leading to EmonCMS installation (which will be the next step, be quite!)
Open a terminal and type
sudo apt-get install apache2 libapache2-mod-php5 php5-gd php5-json php5-mysql php5-curl php5-intl php5-mcrypt php5-imagick
sudo apt-get install mysql-server mysql-client php5 libapache2-mod-php5 php5-mysql php5-curl php-pear php5-dev php5-mcrypt php5-json git-core redis-server build-essential ufw ntp
sudo apt-get install mysql-server
sudo pear channel-discover pear.swiftmailer.org
sudo pecl install channel://pecl.php.net/dio-0.0.6 redis swift/swift
You have got to wait some minutes, Cubieboard is not so speedy! After that:
sudo sh -c 'echo "extension=dio.so" > /etc/php5/apache2/conf.d/20-dio.ini'
sudo sh -c 'echo "extension=dio.so" > /etc/php5/cli/conf.d/20-dio.ini'
sudo sh -c 'echo "extension=redis.so" > /etc/php5/apache2/conf.d/20-redis.ini'
sudo sh -c 'echo "extension=redis.so" > /etc/php5/cli/conf.d/20-redis.ini'
sudo a2enmod rewrite
Now you need to change some permissions. Depending on which distro you are using it changes a bit, as follow.
If you are using Debian Wheezy in a terminal type
sudo pluma /etc/apache2/sites-available/default
else, if you use Debian Jessie or Ubuntu
sudo pluma /etc/apache2/apache2.conf
A text file will be shown, somewhere you can find
<Directory /> and under
<Directory /var/www/> .
Change it to
Save and exit, then restart the web server:
sudo service apache2 restart
If everything is right, opening your preferred web browser on your PC and typing
should show you Apache2 greetings!
You can also activate some kind of dynamic DNS, just like noip.com (free) or dyndns (not free), in order to have a domain associated to your router. Then setting up port forwarding on your router and specific IP address inside your home network will do the job, you will be able to access your webserver on Cubieboard simply typing your domain name in a browser, wherever you are.
But this is more than what this tutorial aims to, if you wanna now more…Google is your friend! or contact me!
Following lines are for those who doesn’t now so much about linux distros, single-board computer, terminal, shell, installations. For sure an IT guy will find them a bit simplistic, but the target is our African friends and whoever just want to start. So please, be patient with my IT mistakes!
Ok, it’s time to start to build a place where I can put my data.
Allright, the cloud is a great thing, encryption is a great resource but…I prefer to have my data. At least, every time I want / I need my data to be only mine.
I know and I’ve been using some nice IoT platforms able to store data: Xively, Thingspeak, Carriots, just to say about. They are good, works well the way I will try to explain I did, but sometimes you need to pay, sometimes you have limited data plans, sometimes you may think “where the hell are my data?”
So I decided to have a personal server. I’m a mechanical engineer, I started few years ago to study about these themes, it requires time and a bit of skills.
What I was looking for was a cheap computer able to collect data and serve them whenever I needed. And, for sure, I wanted a low power computer. 10 years ago this was difficult to find for a non-IT worker.
Things changed with Raspberry Pi. I never bought one, but I feel grateful to Raspberry foundation because of their effort. In a few years a lot of single-board computers grew up, and now you can choose between UDOO, Raspberry, Banana Pi, Orange Pi, etc.
I bought (ok, I funded…) a Cubieboard three years ago. A great piece of hardware, with a growing communities (here the most interesting) which aided me a lot to understand how to move around with installations.
After many installations, re-installations, usually concerning Debian or Ubuntu, I finally landed on Armbian.
Igor Pečovnik , the owner of the website, is a great guy from Slovenia who is building distros for many different single-board computer platforms, have a look here. I don’t know why he is doing this, if there’s a business model or is just for fun, but his work is really great.
So now I’m using Armbian on my Cubieboard A10, a Debian Wheezy version you can download here. There are two versions, “legacy” and “vanilla”, the key difference is which kernel is used: legacy uses an older and stable one, vanilla lies on a newer one, even up to the newest one.
I tried both ones: vanilla doesn’t seem to work well with my webcams (yes, I will show you how to use webcams too), so I decided for legacy.
Installation is not difficult. After downloading the preferred distro, extract the image file: in the archive you will find some files, and a .raw file such as Armbian_5.00_Cubieboard_Debian_jessie_3.4.110.raw
This file has to be flashed on an microSD card.
If you use Windows, ok, shame on you: I can’t help you nothing more then telling you to use the imagewriter.exe file inside the archive, hoping you will decide to cure your Windows-mania…
If you use a Linux distro, well, it is simple: open a terminal, move to the folder containing the .raw file, then just write
dd bs=1M if=filename.raw of=/dev/sdx
as root user, where /dev/sdx is SD card device. Or, which is the same:
sudo dd bs=1M if=Armbian_5.00_Cubieboard_Debian_jessie_3.4.110.raw of=/dev/mmcblk0
Be careful: usually /dev/sda is your system folder, /dev/sdb your home directory, using these you will destroy your system!
Usually SD card are identified by /dev/mmcblk0, depending on the system you are using.
It will take some minutes to complete flash process. Then unmount if mounted, extract, insert in microSD card slot on Cubieboard, connect a monitor and turn on. Better if Ethernet is connected and Internet available for immediate updates.
After a few minutes login prompt will appear: on first boot only root user is present, and password is 1234, you are requested to change it.
Then you can create your personal user, with
(user1 is an example username).
Then you need to insert your user in the sudo group, to have access to some SuperUser functionality:
usermod -aG sudo user1
The system is ready, now!
Ok, there’s no desktop environment neither desktop manager, by now; it is better/simpler to install one.
To install XFCE and LightDM type:
apt-get -y install xorg lightdm xfce4 tango-icon-theme gnome-icon-theme
To install MATE and LightDM:
apt-get -y install xorg lightdm mate-desktop-environment mate-desktop-environment-extras tango-icon-theme gnome-icon-theme pluma
Whatever was your choice, at the end of the installation it is time to reboot PC, so:
After reboot you will have a login screen: get in with your username and password, the system is on!
Maybe now you would like to disconnect the monitor, in order to leave it alone, just as low power companion on your desk. Ok, you can access and control it without any monitor, simply you need to install a VNC client on your computer (I use Vinagre on Ubuntu, many others are available) and a VNC server on the Cubieboard.
So open a terminal on Cubieboard (nice: for some minutes you need to connect your monitor again!) and write
sudo apt-get install x11vnc
In a terminal:
sudo pluma /etc/lightdm/lightdm.conf
find the following lines inside it
[SeatDefaults] #autologin-user= #autologin-user-timeout=0
and uncomment them, then change to
[SeatDefaults] autologin-user=user1 autologin-user-timeout=0
Save and exit terminal, then reboot. You should get in automatically.
Now open menu, system, preferences, startup applications (on MATE; on XFCE maybe it is a little different)
and add (inside “command”)
Save and exit.
Now open your browser, access to your router and change settings in order to permit communication between your Cubieboard and your PC: this means you have to open port 5900, the one used by VNC communications.
While dealing with router, have a look to IP address assigned to your Cubieboard, i.e. 192.168.1.5: you will need to now to access Cubieboard.
Then open your VNC client on your PC, type Cubieboard address (i.e.: 192.168.1.5:5900) and enjoy your single-board computer.
Next ride: we will install a web server and a database to store data.
(to be continued…)