Basic pi setup.

 

Basic setup

-----------------

install jessie os
do updates
install vim mc


Wifi
------

Check Ethernet & Wifi Before continuing make sure the Ethernet cable is connected in and you can ping out from the Pi:

ping 8.8.8.8

You will also want to set up your WiFi dongle. run

sudo shutdown -h

now and then plug in the WiFi module when the Pi is off so you don't cause a power surge.

If you have a Pi 3, or any other Pi with built in WiFi, an external WiFi adapter is not required but you can use one if you need a bigger/external antenna.  When it comes back up check with ifconfig -a that you see wlan0 - the WiFi module.


Install software
-----------------

Next up we install the software onto the Pi that will act as the 'hostap' (host access point). You need internet access for this step so make sure that Ethernet connection is up!

sudo apt-get update
sudo apt-get install hostapd isc-dhcp-server

(You may need to sudo apt-get update if the Pi can't seem to get to the apt-get

repositories) (text above shows udhcpd but that doesnt work as well as isc-dhcp-server, still, the output should look similar) Also install a nice iptables manager with

sudo apt-get install iptables-persistent

You'll get two 'config' screens, say Yes to both


Set up DHCP server

Next we will edit /etc/dhcp/dhcpd.conf, a file that sets up our DHCP server - this allows wifi connections to automatically get IP addresses, DNS, etc. Run this command to edit the file

sudo nano /etc/dhcp/dhcpd.conf

Find the lines that say

option domain-name "example.org";
option domain-name-servers ns1.example.org, ns2.example.org;

and change them to add a # in the beginning so they say

#option domain-name "example.org";
#option domain-name-servers ns1.example.org, ns2.example.org;

Find the lines that say

# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
#authoritative;

and remove the # so it says

# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
authoritative;

Then scroll down to the bottom and add the following lines

subnet 192.168.42.0 netmask 255.255.255.0 {
range 192.168.42.10 192.168.42.50;
option broadcast-address 192.168.42.255;
option routers 192.168.42.1;
default-lease-time 600;
max-lease-time 7200;
option domain-name "local";
option domain-name-servers 8.8.8.8, 8.8.4.4;
}

Save the file by typing in Control-X then Y then return  Run

sudo nano /etc/default/isc-dhcp-server

and scroll down to

INTERFACES=""

and update it to say

INTERFACES="wlan0"

Or whatever the name of your wifi adapter is! close and save the file  Set up wlan0 for static IP If you happen to have wlan0 active because you set it up,  run

sudo ifdown wlan0

There's no harm in running it if you're not sure Next we will set up the wlan0 connection to be static and incoming. Run

sudo nano /etc/network/interfaces to edit the file

Find the line auto wlan0 and add a # in front of the line, and in front of every line afterwards. If you don't have that line, just make sure it looks like the screenshot below in the end! Basically just remove any old wlan0 configuration settings, we'll be changing them up Depending on your existing setup/distribution there might be more or less text and it may vary a little bit  Add the lines


iface wlan0 inet static
address 192.168.42.1
netmask 255.255.255.0

After allow-hotplug wlan0 - see below for an example of what it should look like. Any

other lines afterwards should have a # in front to disable them Save the file (Control-X Y ) Assign a static IP address to the wifi adapter by running

sudo ifconfig wlan0 192.168.42.1

Configure Access Point

Now we can configure the access point details. We will set up a password-protected

network so only people with the password can connect. Create a new file by running

sudo nano /etc/hostapd/hostapd.conf

Paste the following in, you can change the text afterssid= to another name, that will be the network broadcast name. The password can be changed with the text after

wpa_passphrase=

interface=wlan0

driver=rtl871xdrv

ssid=Pi_AP

country_code=US

hw_mode=g

channel=6

macaddr_acl=0

auth_algs=1

ignore_broadcast_ssid=0

wpa=2

wpa_passphrase=Raspberry

wpa_key_mgmt=WPA-PSK

wpa_pairwise=CCMP

wpa_group_rekey=86400

ieee80211n=1

wme_enabled=1


If you are not using the Adafruit wifi adapters, you may have to change the

driver=rtl871xdrv to say driver=nl80211 or something If you are using the Raspberry Pi 3's internal WiFi adapter, comment out thedriver=rtl871xdrv

 line altogether: Save as usual. Make sure each line has no extra spaces or tabs at the end or beginning - this file is pretty picky!  Now we will tell the Pi where to find this configuration file. Run

sudo nano /etc/default/hostapd


Find the line #DAEMON_CONF="" and edit it so it says


DAEMON_CONF="/etc/hostapd/hostapd.conf"


Don't forget to remove the # in front to activate it!

Then save the file

Likewise, run


sudo nano /etc/init.d/hostapd

and find the line


DAEMON_CONF=


and change it to


DAEMON_CONF=/etc/hostapd/hostapd.conf


Configure Network Address Translation Setting up NAT will allow multiple clients to connect to the WiFi and have all the data 'tunneled' through the single Ethernet IP. (But you should do it even if only one client is going to connect) Run

sudo nano /etc/sysctl.conf

Scroll to the bottom and add

net.ipv4.ip_forward=1

on a new line. Save the file. This will start IP forwarding on boot up Also run

sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward "

to activate it immediately  Run the following commands to create the network translation between the ethernet port  eth0 and the wifi port wlan0


sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT

sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT


You can check to see whats in the tables with


sudo iptables -t nat -S

sudo iptables -S


To make this happen on reboot (so you don't have to type it every time) run


sudo sh -c "iptables-save > /etc/iptables/rules.v4"


The iptables-persistent tool you installed at the beginning will automagically reload the configuration on boot for you. update hostapd (maybe) If you are running Raspberry pi kernel 4.4.13-v7+ or greater (check your kernel version with uname -a), you do not need to do this step. if you are using the Raspberry Pi 3 built-in WiFi or are not using RTL8192-like WiFiadapter, then skip this step! before we can run the access point software, we have to update it to a version that supports the WiFi adapter. First get the new version by typing in


wget http://adafruit-download.s3.amazonaws.com/adafruit_hostapd_14128

Then install it.

Apache2 web server and php:
----------------------------

sudo apt-get install apache2 -y

sudo apt-get install php5 libapache2-mod-php5 -y


Database:
---------------

Install MariaDB on Raspbian


With the new version of Raspbian, MariaDB is now present in the official repositories, which until now was not the case! To install it, nothing more simple therefore, you just need to run the following command:

sudo apt-get install mariadb-server

If you already have MySQL installed, it is likely that the package manager notifies you of a conflict and asks if it needs to uninstall MySQL. In this case, answer yes. During the installation, MariaDB will configure itself. It’s up to you to provide the administrator account for the database.  This done, it should ask you if you are sure to want to go under MariaDB. Again, answer yes. Once the installation is complete, you will be able to access MariaDB as you did with MySQL, simply with the following command:

mysql -u user -p


Setup gui
-------------

sudo apt-get install xinit

sudo apt-get install lxde-core lxterminal lxappearance

sudo apt-get install lightdm

sudo reboot

Web database admin
-----------------------------

sudo apt-get install phpmyadmin

Add your own passwords

Remote desktop
-----------------------

sudo apt-get install xrdp

Bluetooth
--------------

Make sure system sees the bluetooth device

    lsusb

upgrade the system software:

    sudo apt-get update
    sudo apt-get upgrade

Install the bluetooth software:

sudo apt-get install bluetooth blueman bluez python-gobject python-gobject-2

Open a Terminal window and edit the /etc/rc.local file with:

    sudo nano /etc/rc.local

And add the following to the end of the file, just before the exit 0 line:

    sudo hidd -i hci0 --connect 00:07:61:B4:7E:81

replacing the MAC address with the MAC address of your keyboard or computer.

Comments

Popular posts from this blog

Guiless?

MSOffice vs Libreoffice

Raspberry pi zero.