Sunday, November 29, 2015

Setting up the RPI 2 Server


For this i am assuming you already have RPi 2.

Install an OS on your RPi. Now here is the catch you need a monitor.
Simply borrow the monitor from your PC plug it in turn it on and put in your FORMATED SD CARD. Also if you haven't at least download some Linux distribution on a virtual machine if you at least don't have it as your primary | secondary OS.

OK you have your RPi plugged in with the monitor, your adapter in the power, your borrowed keyboard (&mouse) also AND your Ethernet cable connecting your RPi and your router.  Since RPi is so small and doesn't require much space you can leave it connected to the router AND hide it somewhere.

Installation done, now to install LAMP server. I have followed this tutorial.
It will work on RPi also. So

sudo apt-get update
sudo apt-get install apache2 mysql-server libapache2-mod-auth-mysql php5-mysql php5 libapache2-mod-php5 php5-mcrypt


Yeah next install the database.
sudo mysql_install_db
Ok, so far so good. We have the basics. But here is the catch.
We don't want to create the login mechanics available online at all times (as they might be exploited).
So we will have to (eventually) create a C++   program that will be used for registering users (or home members) locally and more securely. For that we need to install the necessary libraries to be able to communicate with MySql.
sudo apt-get install libmysqlclient-dev

But we want to use the C++ connector (and all the advantages of OOP)

apt-get install libmysqlcppconn-dev

OK, so we do have that installed. But still we will need phpmyadmin to be able to actually communicate with mysql databases in a better fashion than a command line.

To install phpmyadmin i used this link as a reference. 
Basically you need to install it.
sudo apt-get install phpmyadmin apache2-utils
Then you need to select the apache2 server on installation , insert your mysql password, enter the password you want to log in into phpmyadmin and choose to configure it with dbconfig-common.

Now after all that we need to tell apache to include the phpmyadmin configuration file for apache.

To do this  you first need to find your apache configuration file

On RPi that will be in /etc/apache2/apache2.conf

Add a line
Include /etc/phpmyadmin/apache.conf
Great. Now to get it to work
sudo service apache2 restart

And enter
yourraspberrypi_ipaddress/phpmyadmin

Mine was
192.168.1.3/phpmyadmin


SECURITY NOTE
This is all well and fine but phpmyadmin is not famous for its security.
And we want our security. Since we don't want everyone to be able to control our home devices. We will need to eventually lock down that folder with a username/password apache protection mechanism. That will be added in a later tutorial. 


NEXT: SESSION MANAGMENT FOR OUR HOME SERVER

No comments:

Post a Comment