11
RASPBERRY PI CONFIGURATION GUIDE Step 1: Gather Materials Required SD Card o Recommended an 8GB class 4 SD card – ideally preinstalled with NOOBS. Display and connectivity cables o Any HDMI/DVI monitor or TV should work as a display for the Pi . For best results, use one with HDMI input, but other connections are available for older devices. Use a standard Ethernet cable for internet access. Keyboard and mouse o Any standard USB keyboard and mouse will work with your Raspberry Pi. Power supply o Use a 5V micro USB power supply to power your Raspberry Pi. Be careful that whatever power supply you use outputs at least 5V; insufficient power will cause your Pi to behave in strange ways. Not essential but helpful to have Internet connection o To update or download software, we recommend that you connect your Raspberry Pi to the internet either via and ethernet cable or a wifi adapter. Headphones o Headphones or earphones with a 3.5mm jack will work with your Raspberry Pi. Step 2: Download Raspbian Wheezy (Demo) Download the package here: http://www.raspberrypi.org/downloads Step 3: Initialize SD Card using Disk Utility (Demo)

Workshop RasPi Melaka

Embed Size (px)

DESCRIPTION

Raspi Jam Melaka

Citation preview

RASPBERRY PI CONFIGURATION GUIDEStep 1: Gather MaterialsRequired SD Card Recommended an 8GB class 4 SD card ideally preinstalled with NOOBS. Display and connectivity cables Any HDMI/DVI monitor or TV should work as a display for the Pi . For best results, use one with HDMI input, but other connections are available for older devices. Use a standard Ethernet cable for internet access. Keyboard and mouse Any standard USB keyboard and mouse will work with your Raspberry Pi. Power supply Use a 5V micro USB power supply to power your Raspberry Pi. Be careful that whatever power supply you use outputs at least 5V; insufficient power will cause your Pi to behave in strange ways.Not essential but helpful to have Internet connection To update or download software, we recommend that you connect your Raspberry Pi to the internet either via and ethernet cable or a wifi adapter. Headphones Headphones or earphones with a 3.5mm jack will work with your Raspberry Pi.

Step 2: Download Raspbian Wheezy(Demo)Download the package here: http://www.raspberrypi.org/downloadsStep 3: Initialize SD Card using Disk Utility(Demo)Step 4: Copy the Wheezy Image onto your SD Card(Demo)Step 5: Basic Pi ConfigurationThe Raspberry Pi configuration tool called "raspi-config" To edit raspi-config, just type sudo raspi-config command from the terminal( if you need need to change a few options).

This will take you to a Raspberry Pi configuration screen. You'll see this only the first time. The options are:

1. Select Expand Filesystem to use your whole SD card (instead of only 2GB).

2. Select Change User Password and select new password for user pi. This is really good idea to change the default password, because you will open the Raspberry Pi to the internet.

3. Select your timezone from Internationalisation Options / Change Timezone.

4. Select Advanced Options / Memory Split: 944 This overrides gpu_mem

5. Advanced Options (SSH): Enable This will enable secure shell access, which means that you can control your Raspberry Pi from a remote computer (extremely useful)

Choose Finish and rebootUse the following code to reboot your Raspberry Pi:

sudo rebootStep 6: Run package updates

On the command line, type in:sudo apt-get updatethen type insudo apt-get upgrade

when done:sudo reboot

---------------------------------------------------------LOGGING INTO YOUR RASPBERRY PI

The default login for Raspbian is usernamepiwith the passwordraspberry# Note you will not see any writing appear when you type the password.This is a security feature in Linux.

After you have successfully logged in, you will see the command line prompt pi@raspberrypi~$

To load the graphical user interface, type startx and press Enter on your keyboard.

SSH (ACCESSING RASPBERRY PI VIA WINDOWS PC)

At this point, find the IP address of your raspberry pi with the following command:

ifconfig

In the second line of the output you will see "inet addr: " followed by a number to the effect of 192.168.1.1 (yours will be slightly different, but you get the idea). Write this number down and bring up your SSH client. For this example we use an application called Puttyas our SSH client.

Use ssh to get back to logging into your Raspberry Pi,ssh [email protected](or what ever address your IP scanner shows)

---------------------------------------------------------WRITING YOUR FIRST PYTHON PROGRAM Raspbian comes preloaded with Python, the official programming language of the Raspberry Pi and IDLE 3, a Python Integrated Development Environment. Python can be started in three different ways:1. As the interactive interpreter2. Directly executing a script from the command line3. As an Integrated Development Environment (IDE)Activity 1: Python Calculator>>>2+24The statement 2+2 will be displayed on main prompt (>>>), while the output will be displayed on the next row without prompt. You can try the following activities and the result.i) >>>(60+40)/10ii) >>>9/2iii) >>>(3+20)*4Activity 2: Selamat Datang>>> print "Selamat Datang di Pemrograman Python"Activity 3: Using VariableExample 1>>>harga = 100>>>diskaun = 25>>>harga diskaun [press Enter to see the result]Example 2>>>(x, y, z) = (1, 2, 'belajar Python')>>>x [press Enter to see the result]>>>y [press Enter to see the result]>>>z [press Enter to see the result]

Example 3>>>(x, y) = (10, 20)>>>x [press Enter to see the result]

>>>y [press Enter to see the result]

>>>(x, y) = (y, x)>>>x [press Enter to see the result]

>>>y [press Enter to see the result]

Activity 4: Turn Hostname to IP Address

Click File > New Window, which will then bring up a new blank window which you can type in.Then, type the following in your new window:#program menukar nama Host menjadi alamat IPimport socketwebsite = input(masukan nama website : )ip = socket.gethostbyname(website)print(*******************************************)print(alamat IP : , ip)print ( **************************************************)# akhir program disiniNow click File > Save As and in the new dialogue window that pops up, call your file "test.py" and click "Save".Let's run that program you just wrote!Click Run > Run Module or simply press F5.

Activity 5: Receiving Input DataClick File > New Window, which will then bring up a new blank window which you can type in.Then, type the following in your new window:#my first Python programusername = input("Hello, I'm Raspberry Pi! What is your name? ")print ('Nice to meet you, ' + username + ' have a nice day!')Now click File > Save As and in the new dialogue window that pops up, call your file "hello.py" and click "Save".Let's run that program you just wrote!Click Run > Run Module or simply press F5.When you get prompted "Hello, I'm Raspberry Pi! What is your name?" in the IDLE 3 window, type your name and press Enter. ---------------------------------------------------------

INSTALLING THE RASPBERRY PI WEB SERVERYou can do this installation via Raspberry Pi SSH or via the terminal on the actual Pi.

1. First we will need install the apache2 package:sudo apt-get install apache2 -y2. Now thats all you need to do to have the server up and running. To check that it is working you should be able to enter the Pis IP address. If you dont know the IP you can enter the following line hostname -I3. Browse to the IP address in a browser and you should get a page like the one below.

3. Now youre able to edit this basic file by simply entering the following command.sudo nano /var/www/index.html4. You can now add as many new webpages as you want in the www folder and they will be viewable from the browser.

5. This is a very basic server and is great if you just want to learn HTML, JS or CSS but if youre after PHP (Used for dynamic web pages) then read on.

6. To install PHP we will need to first get the PHP package so lets download the PHP5 module for apache. To do this enter the following:sudo apt-get install php5 libapache2-mod-php5 -y7. Now we can place php files in the www and they will be processed and displayed. For an example lets make a file called example.phpsudo nano /var/www/example.php8. In this file add the following: tags).Install Raspberry Pi WordPressWordPress is a content management system/blogging software that is used by over 60 million websites. Amongst the top 10 million websites on the web 23.3% of these use WordPress. (January 2015).It is very easy to install & learn the basics making it a great way to launch your very own website or blog. Installing Raspberry Pi WordPress on to our web server is dead easy and can be done in just a few steps detailed below.1. Now we have already installed PHP but we will also need MySQL and the MYSQL PHP packages.sudo apt-get install mysql-server php5-mysql -yYou will be asked for a root password make sure you remember this as we will need it to access the database.2. We will need to now download and extract the WordPress package that we can easily download. To do this do the following commands:cd /var/wwwsudo chown pi: .rm *wget http://wordpress.org/latest.tar.gztar xzf latest.tar.gzmv wordpress/* ./rm -rf wordpress latest.tar.gzsudo chown -R -f www-data:www-data /var/www3. Now thats installed we will need to setup a database to connect to.

Now we could install PHPMyAdmin for database management but instead we will do it via command line.First we need to use the mysql command to login, use the p flag for the password and u for the username.

Leave no space between the flag and required text.mysql -uroot -ppassword4. Now lets create a database for this tutorial lets call it WordPress.create database wordpress;5. You should now see a success statement that looks something like the following:Query OK, 1 row affected (0.00)6. Now lets exit out of MySQL prompt by pressing Ctrl + D

7. Now in a browser go to the Pis IP address and you should be presented with a WordPress setup screen. Fill in the relevant information such as:

Database Name: wordpress

User Name: root

Password: (Password you created at the MYSQL setup)

Database Host: localhost

Table Prefex: wp_

8. Now you should be hit next and be able to complete the installation.