Chapter 18:

DATA SURVEY

Creating a Mobile Wi-Fi Server for Surveys and Data Collection

This guide explains how to set up a mobile Wi-Fi server, ideal for delivering questionnaires or surveys to a group, such as customers or lecture attendees. This setup is perfect for interactive feedback sessions and collects responses in a database format.

Overview

  • Purpose: Serve surveys/questionnaires through a mobile Wi-Fi server and collect responses in a database.

  • Technologies Used: PHP, MySQL, NGINX, Lighttpd, PHPMyAdmin.

Prerequisites

  • Familiarity with basic Linux commands and web server setup.

  • Hardware: Raspberry Pi or similar device.

  • Software: NGINX for web serving and captive portal, PHP, MySQL.

Preparation

  1. Captive Portal and Hotspot Script: Start by downloading a pre-written script for setting up a captive portal and hotspot. This can be found at Jerry Ryle's GitHub Repository.

    wget https://github.com/jerryryle/rogueportal/releases/download/v1.3-RaspbianBuster/rogueportal_1.3_armhf.deb

  2. Pre-Installation Configuration: Make some changes to automate the installation process. Run the following commands:

    sudo debconf-set-selections <<< "macchanger acchanger/automatically_run boolean true"

    sudo debconf-set-selections <<< "iptables-persistent iptables-persistent/autosave_v6 boolean true"

    sudo debconf-set-selections <<< "iptables-persistent iptables-persistent/autosave_v4 boolean true"

    To specify your Wi-Fi SSID:

    sudo debconf-set-selections <<< "rogueportal rogueportal/ssid string YourSSID"

Installation Steps

  1. Install Rogueportal Package:

    sudo apt install ./rogue*.deb

  2. Set Up Lighttpd for PHPMyAdmin:

    Configure Lighttpd to serve your PHPMyAdmin page and test contents.

    • Edit Lighttpd configuration:

      sudo nano /etc/lighttpd/lighttpd.conf

      Set the port to 8080.

    • Reconfigure PHPMyAdmin:

      sudo dpkg-reconfigure phpmyadmin

    • Create a symbolic link to the web directory:

      sudo ln -s /usr/share/phpmyadmin /var/www/html

    • Enable FastCGI modules:

      sudo lighttpd-enable-mod fastcgi fastcgi-php

      sudo service lighttpd force-reload

  3. Configure Firewall Rules:

    To allow connections to the hotspot, edit your iptables rules:

    sudo nano /etc/iptables/rules.v4

  4. Support PHP in NGINX:

    To handle PHP requests, include the following in your NGINX configuration (/etc/nginx/sites-available/default) within the server { } block:

    location ~ \.php$ {

    include snippets/fastcgi-php.conf;

    fastcgi_pass unix:/run/php/php7.0-fpm.sock;

    }

Accessing the Server

  • Connect to the Wi-Fi hotspot created (SSID as set earlier).

  • Access the PHPMyAdmin page or other contents served through Lighttpd or NGINX.

Note: This guide assumes a basic level of technical proficiency with Linux systems and web server management. Ensure you have the necessary hardware and software ready before proceeding.