Setting up Raspberry Pie Server With out any Display and LAN Connection(Using mobile Hot spot and WiFi)

I recently bought a Raspberry Pie3 Model B to setup a mini server for my IOT platform. I didn't have a display or a LAN Connection to setup my raspberry pie server. So, I figured out a way to setup a Raspberry Pie server with a simple mobile hotspot and few Linux tricks.

Basic Requirements :
  • Raspberry Pie (This process works for any version of Pie board)
  • Mobile Hotspot (May be mobile phone hot spot or WiFi router)
  • Linux system (at least Live boot of any Linux distribution does the trick)
1. Raspberry Pie :
  • Buy a Raspberry Pie from local electronics store or online.
  • Also buy at least 8GB memory card(class 10 is preferred for speed and reliability).
  • Download the lite version of Raspbian OS from Raspberry Pie website https://www.raspberrypi.org/downloads/raspbian/
2. Setting up WiFi :
  • Turn on Mobile Hotspot.
  • Setup hot spot SSID and Password.
                               OR
  • if you have a mobile hot spot creator that turn it on and note the exact SSID.
  • if you have a router than you ca skip the "Network Configuration" step.
3. Installing Raspbian :
  • Download and extract the lite version of Raspbian OS from https://www.raspberrypi.org/downloads/raspbian/.
  • Insert your SD card in to your computer. Mine in this case is a Sandisk Ultra class 10 16 GB memory card.
  • Open the Gnome Disk Utility from terminal by the following command "sudo gnome-disks"

  • Now search for your SD card in the left navigation panel and select it.

  • On the top right corner you see a icon with 3 horizontal lines. Press it and select the "Restore Disk Image.." option.

  • A pop up appears and asks for you to browse the image file.

  • Select the Browse button and browse the extracted Raspbian Lite Image file. Press "Start Restoring..".

  • It asks for the conformation showing the disk information for one last time. Press "Restore" and the process begins as it shows the progress. With in few minutes the SD card will be written with the image and ready for next step. Do not remove SD-card from computer as we need to do some tweaks before we get going.



  • After the completion of this process, we can see two partitions in the SD-card. One is named as "boot" and the other is named as "rootfs".

4. Network Setup :
  • As we need to work with out the display, we need to access our Pie over SSH.
  • But for the SSH to work we need network connection.
  • If you have a WiFi router with LAN cable and Raspberry Pie 3 which has Ethernet port you can skip this step.
  • If you have a Pie Zero or if you don't have a wifi router then first open the file manager and open the "rootfs" partition in the SD-card.

  • Now go to /etc/network folder and open the file "interfaces".

  • Add the following lines at the end of the file.
                   auto wlan0
                   allow-hotplug wlan0
                   iface wlan0 inet dhcp
                               wpa-ssid "WIFINAME"
                               wpa-psk "WIFIPASSWD"

  • Replace WIFINAME with your wifi name and WIFIPASSWD with your wifi password. Do not remove the double quotations.


  • Save and close the file. This ends the network configuration settings.
5. Setting up SSH and using Pie over SSH :
  • Now go to home folder and open the "boot" partition.

  • Create a file with name "ssh" (all small letters) with out any extensions.

  • That's it. Setup is complete now its time to power on the Raspberry pie.
  • Insert the memory card in to the raspberry pie and power the board.
  • Wait for a while as the Pie boots up for first time. Watch the connected users tab in your phones hotspot management or in your routers home page.
  • Observe for the user with user name "raspberrypie" and note its ip address.
 

  • Connect your system to the same wifi to which raspberry pie is connected and open terminal in your sysem.
  • Type the command "ssh pi@<Ip address of Pie>" and type enter.
  • First time it asks conformation to add the ssh key, type yes and enter the password. The default password is "raspberry".
  • Then you will be logged in to the raspberry pie via ssh.


  • After logging in to pie update and upgrade the packages before configuring the pie using the command "sudo apt-get update && sudo apt-get upgrade"


  • Now its time to configure raspberry pie settings.
  • Type "sudo raspi-config" and press Enter.


  • Your first step is to change the password. It is as follows :




  • Now set your local Time Zone and local Language :









  • Latest releases of Raspbian OS resizes the partition automatically during its first boot. But to be sure that the filesystem has expande and our OS is using the whole space of the SD-card we will try to expand the file system manually.
  • If the file system is already expanded, there is no problem in doing this step again. Nothing will be lost.
  • Do it as shown below :



  • When this is completed by using right arrow key go to <Finish> opton and type Enter.
  • It will ask you if you are willing to reboot. Select "Yes" so that pie will reboot and all your settings come to effect.


  • Now wait for sometime for pie to reboot.
  • Login to Pi again using ssh and the password will be your new password that you set.
  • Now install the essential packages for a server by typing the following command
                       "sudo apt-get install apache2 php mysql-server mysql-client"


  • In order for you to work with html pages we need to know the default folder of html. It is in the "/var/www/html" directory.
  • Now we will create a symbolic link to that folder and we will change the access permissions of that folder for us to work with.
  • Type the following commands :
                    ln -s /var/www/html ./html
                    sudo chown pi /var/www/html
                    sudo chgrp pi /var/www/html
  • Now there will be a symbolic link of the html folder where you can store your web pages.
  • By default there will be a html page with name Index.html.


  • Open up your browser and type the IP address of raspberry pie and hit enter. You will see a apache html page.
  • It means you have done every thing correctly and your apache server is up and running.


  • Now modify or replace the default web page with your own web page. That's it, youset up a mini raspberry pie server.

          I hope you have enjoyed this tutorial. I would like to listen if I have missed any thing or any additional information that i have missed. Please ask me what ever doubts you have.
          This can be further extended by port forwarding the ip of raspberry pie and assigning a DNS host name and build a mini IOT server to control sensors connected to raspberry pie which I will be doing in next tutorial.

Comments

Popular posts from this blog

Setting up code composer studio for Tiva C-series(TM4C123GH6PM Launch Pad)

Configuring GPIO Pins in TM4C123GH6PM( TIVA C-Series Launch Pad)