"A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects." (Robert A. Heinlein)

Thursday, 25 June 2015

More work on the Raspberry PI


I've been working a little more on my Raspberry PI based server. After installing Minidlna server my Raspberry PI server needed some easy way to transfer media files into the USB disk. Sharing the disk with Samba has been, to me, the obvious solution. Also I installed the basis of a LAMP server (Apache2, MySQL, PHP5) for future installation of server applications.

Sharing a disk with Samba

The first step has been so installing samba from command line apt-get


sudo apt-get update
sudo apt-get install samba samba-common-bin
then I edited samba configuration file
sudo vim.tiny /etc/samba/smb.conf
where I added the definition instructions for sharing the USB disk
[usbdisk]
comment = Raspberry PI USB disk
path = /media/usbdisk
browsable = yes
guest ok = yes
read only = no
create mask = 0777
directory mask=0777
public= yes
only guest = no
force user = pi
force group = users
To keep things on the easy-to-use side I set the share for a public “guest” use without asking for passwords. Since my Raspberry server is still in a experimental status I don't have, not yet at least, many security worries to think about.
I tested the configuration with the testparm command
testparm /etc/samba/smb.conf
and eventually restarted the samba service.
sudo service samba restart
Just one last little thing … once the share was ready I tested it trying to copy a file but I failed receiving a permissions error. I double-checked samba configuration many times until I discovered the problem was in file system permissions instead. The USB disk I mounted on the Raspberry PI has been previously used on my NAS and it kept its permissions that Raspberry didn't , of course, understand. Changing whole disk ownership …
sudo chown -R pi:pi /media/usbdisk/
solved everything.
This to remember myself that, while working with network shares, permissions are often double-sided.

Installing a LAMP server

Installing all the components of a LAMP server it's matter of just one big apt-get command:
sudo apt-get update
sudo apt-get install apache2 php5 mysql-client mysql-server vsftpd
Secure FTP demon (vsftpd) is not strictly necessary but it's definitively useful for transferring files without having to pass by the samba shared disk. Installation downloaded all needed files then proceeded flawlessly stopping only to ask for MySQL administrator password.
Last but not least, nce the installation completed, I checked Apache server was working (the famous “It works” page) then installed the PHP based MySQL administration application phpMyAdmin.
sudo apt-get install phpmyadmin
I will not, probably, need doing heavy administrative tasks on my experimental server but phpMyAdmin is a valuable tool, worth to be installed, and a good test to check everything is properly installed.

No comments :

Post a Comment