Setup Raspberry Pi


Intro

https://www.raspberrypi.org/

Raspberry Pi is a tiny form-factor, Linux based computer that was originally designed for students to prototype

Runs a compact version of Linux:

  • Runs Raspian - a Linux distro based on Debian
  • NOOBS - New Out Of the Box Software - package
  • Has Python and Java installed

Uses a Micro-SD card instead of a HDD/SDD

Has many extension ports and pins to facilitate connecting many different sensors, LEDs, motors, etc


OS Installation

Download the latest version of Raspian - https://www.raspberrypi.org/downloads/raspbian/

Download a SD card formatter - https://www.sdcard.org/downloads/formatter/

Download an SD image copier - https://sourceforge.net/projects/win32diskimager/

  1. Plug the SD card into your Windows computer
  2. Format it if necessary
  3. Run Win32DiskImager to copy the image to the SD card
  4. Plug the SD card into the Raspberry Pi and boot it up
  5. Follow the prompts to setup the OS

Set the time

The time may not be set properly so open the terminal and run the following command:


-- displays the current time set by the system
$ date

-- set the current date/time to 2:30 pm - sept 25 2019
$ date -s "SEP 25 2019 14:30:00"

Setup

Download IP Scanner for your Windows computer here: https://www.advanced-ip-scanner.com/

  1. Open Pi => Preferences => Respberry Pi Configuration
  2. On the System tab
  3. Set the following:
    • Password - change it to something - P@ssw0rd
    • Hostname - change it to something unique - JD
    • Navigate to the Interfaces tab
    • Enable the following:
      • Camera
      • SSH
      • VNC
      • SPI
      • I2C
      • 1-Wire
      ...and click OK
    • Run the command following commands to update the system:
      
      $ sudo apt-get update
      $ sudo apt-get upgrade
      $ sudo apt-get update
          

Apache

Install apache2 like so:

  1. Install vsftpd by running the following command:
    sudo apt-get install vsftpd
  2. Edit the vsftpd.conf file by running:
    sudo vi /etc/vsftpd.conf

    ...and alter the following lines:
    • anonymous_enable=NO
    • local_enable=YES
    • write_enable=YES
    • local_unmask=022
  3. Restart the vsftpd service by running the command:
    sudo systemctl restart vsftpd
  4. Install Apache by running the following command:
    sudo apt install apache2

Download FileZilla FTP Client for Windows here: https://filezilla-project.org/

Determine the Pi's IP address by typing:


$ ifconfig

Run FileZilla and insert the IP address (10.163.37.227), username (pi), and password (P@ssw0rd)

Start/Stop the Apache server by running:


$ systemctl start apache2

VNC

Download Tight VNC for your Windows computer here: https://www.tightvnc.com/

  1. Open the Terminal and type ifconfig to determine the IP of the Pi - 10.163.37.227
  2. Alter these settings on the Pi to configure VNC Server:
    1. Open VNC Server (in the upper right-hand corner) and click the elipsis to enter the Options... page
    2. Under the Security panel:
      • Change the Encryption to Prefer Off
      • Change the Authentication to VNC Password and set a password
    3. Navigate to the Connections tab and take note of the Port # that VNC Server is broadcasting over (5900)
    Click Apply and then OK
  3. Run VNC Viewer on your Windows machine, and type in the IP to access the Pi remotely

MySQL

https://www.mysql.com/

Install it like so:


$ sudo apt install mariadb-server

PHPMyAdmin

https://www.phpmyadmin.net/

https://pimylifeup.com/raspberry-pi-phpmyadmin/

Install phpmyadmin

  1. 
    $ sudo apt install phpmyadmin
        
  2. When prompted, select the apache2 option by pressing SPACE and ENTER
    There must be an asterisk in the option!

    If you miss pressing SPACE, run this command to get back to the option:

    
    $ sudo dpkg-reconfigure phpmyadmin    
        
  3. When asked whether or not to install a database, choose YES
  4. Type a master password to connect to the MySQL db and confirm it when prompted
  5. We will need to create a new user as root is disabled, so, login to the MySQL CLI:
    
    $ sudo mysql -u root -p    
        
    and enter your password when prompted
  6. Now run this command to create a new MySQL user with full privileges:
     
    mysql> GRANT ALL PRIVILEGES ON database_name.* TO \'username\'@\'host\';
    
    -- set the username and password appropriately
    
    -- we\'ll use \'admin\' and \'P@ssw0rd\'
    MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO \'username\'@\'localhost\' IDENTIFIED BY \'password\';      
        

    Exit the CLI by typing quit and pressing ENTER

Now we'll have to edit the config files

  1. Edit the apache2.conf file by typing:
    sudo gedit /etc/apache2/apache2.conf
    - or use nano or vi if you havent installed gedit
    Add the following line to the end of the file so that the phpmyadmin.conf file is loaded when apache2 is loaded:
    Include /etc/phpmyadmin/apache.conf
    Save and exit
  2. Restart the apache2 service by typing:
    sudo service apache2 restart

Configure NGINX

  • To configure NGINX, we need to create a link between the phpmyadmin folder and our root html folder:
    sudo ln -s /usr/share/phpmyadmin /var/www/html

Log in to PHPMyAdmin

  • Log in by typing the IP followed by /phpmyadmin in a web browser:
    http://10.163.37.227/phpmyadmin

Logging in as root is now disabled as it is a security risk


Tomcat

Install Tomcat by typing the following commands:


$ sudo apt install tomcat9
$ sudo apt install tomcat9-docs
$ sudo apt install tomcat9-examples
$ sudo apt install tomcat9-admin

Edit the /etc/tomcat9/tomcat-users.xml file to setup manager-gui & admin-gui roles
Tomcat Admin and Manager can only sign on through localhost


-- Open the file
$ sudo gedit /etc/tomcat9/tomcat-users.xml

-- Add this to the file:
<tomcat-users ...>
      
  <role rolename="manager-gui" />
  <role rolename="admin-gui" />
  <user username="pi" password="P@ssw0rd" roles="manager-gui, admin-gui" />
<tomcat-users>  

Samba

Samba is used to integrate Linux/Unix servers into a Windows Active Directory environment

Install samba by running the following command:


$ sudo apt-get install samba

Webmin

http://webmin.com

To install dependencies type:


$ sudo apt-get install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl apt-show-versions python 

Get the Webmin install file here:
https://sourceforge.net/projects/webadmin/files/webmin/1.850/webmin_1.850_all.deb/download

And install it like so:


$ sudo dpkg --install webmin_1.850_all.deb

You can access it from a web-browser either locally at localhost:10000 or remotely at the IP - 10.163.37.227:10000