HeavenCore | IT Solutions Built on Open Source Software
View Thread
 Print Thread
Raspberry Pi - Quick Start Guide for LAMP
admin
Just incase anyone else gets one and wants to know what to do - i'm gonna jott my notes here (I'm making a LAMP box).

Step 0 - Buying Stuff

The Pi does not come with flash card & power - i decided to go with the following:

http://www.amazon...B004TS1IFK - Kingston Technology 32GB Full Size SDHC Class 10 Flash Card
http://www.amazon...B007W3F6CA - Nokia AC-10X Micro USB Charger for Nokia Lumia 710 (5v 1500ma)

You need a micro usb charger (not mini usb) that does 5v and at least 750ma
In regards to the SD card, the debian image requires a card of at least 2GB, if you get a bigger one make sure you have a SDHC card reader etc.

You'll also need a HDMI cable (and ethernet cable)

I found the Pi to be very picky about power and SD cards (2 old ones i had didnt work), there is a list of tested cards & power supplies however:

http://elinux.org...s#SD_cards - the amazon card i linked above is on this list.

Step 1 - flashing the card:

First, i downloaded Win32 Disk Imager: http://www.softpe...ager.shtml
Second, i downloaded the Debian “squeeze” image: http://www.raspbe.../downloads & extracted the img file

I then wrote the image onto the SD card using Win32 Disk Imager:

[img]http://continuum.heavencore.co.uk/Uploads/RaspberryPi_Flashing.png[/img] is not a valid Image.

I then inserted the card into the pi, plugged in the hdmi, keyboard & power:

[img]http://continuum.heavencore.co.uk/Uploads/RaspberryPi_Pi.jpg[/img] is not a valid Image.
[img]http://continuum.heavencore.co.uk/Uploads/RaspberryPi_Boot.jpg[/img] is not a valid Image.

Step 2 - Logging in and testing GUI:

Logged in with the default debian squeeze credentials: (i'll change this password later - Step 6)

Username: pi
Password: raspberry

Once at the standard linux prompt "pi@raspberrypi:~$" - type the following to start the GUI:

Download source  Code
startx




after 10 seconds or so you should be in the GUI.

This is probably the last time i'll ever use the gui *facedesk*

[img]http://continuum.heavencore.co.uk/Uploads/RaspberryPi_Desktop.jpg[/img] is not a valid Image.

Step 3 - Connecting (and enabling) via SSH:

I prefer to keep the pi in another room with no keyboard & mouse, i'll controll it using SSH (via putty)
  1. Shutdown the pi
  2. Attached a network cable (miles easier that wifi at this stage)
  3. Booted & logged back in
  4. sudo bash
  5. ssh-keygen -t rsa
  6. sudo mv /boot/boot_enable_ssh.rc /boot/boot.rc


Next, i get the IP using:

Download source  Code
ifconfig -a




Then, over on the windows PC i connect using Putty (Download: http://www.chiark...nload.html)

[img]http://continuum.heavencore.co.uk/Uploads/RaspberryPi_Putty.jpg[/img] is not a valid Image.

Step 4 - Setting static IP

I dont want the pi to get a DHCP address as this could change, so we configure the pi to use a static IP:

  1. cd /etc/network (Change dir)
  2. ls -l (Note: interfaces)
  3. more interfaces (opens the file, note the DHCP setting on the ethernet line
  4. sudo nano interfaces (opens the file in an editor)
  5. use arrow keys to put your cursor at dhcp and replace with the word static
  6. add the following lines underneath (making sure to use the IP it's currently using - see step 3.4)

Download source  Code
   address 192.168.0.111
   netmask 255.255.255.0
   network 192.168.0.0
   broadcast 192.168.0.255
   gateway 192.168.0.1



  1. Hit Ctrl+X to exit, when prompted to save hit Y then Enter to confirm the filename
  2. Repeat step 3 to double check everything saved OK
  3. reboot the box (sudo reboot)


Step 5 - Changing hostname

I have a naming convention on my network (so i can easily spot unknown devices - so to change the hostname:

  1. sudo nano /etc/hostname
  2. Change the hostname
  3. Hit Ctrl+X to exit, when prompted to save hit Y then Enter to confirm the filename
  4. sudo /etc/init.d/hostname.sh start
  5. hostname (just to confirm) (ignore the "Unable to resolve host xxx" message)
  6. sudo reboot (Wait for reboot then log back in)
  7. sudo nano /etc/hosts (to open the hosts file)
  8. replace instances of raspberrypi with your new hostname then save as usual


Step 6 - Changing Password

Always good to change default passwords!

Download source  Code
passwd




Step 7 - Tidy up MOTD

When you login you get loads of crap about GNU licencing etc, to remove that (or change it) (whilst keeping the usefull version info etc):

Download source  Code
sudo nano /etc/motd.tail




Edit as you like & save & close (Ctrl + X, Y Then Enter)

Step 8 - Backup PI

I then backed everything up that I've done so far (because next step risks breaking everything!)

  1. sudo shutdown now
  2. wait for Debian to confirm everything has stopped & entered single user mode
  3. power off the pi and remove card
  4. install card into PC
  5. start the "Win32 Disk Imager" software we used in step 1
  6. give the image path a name and select your card as the device
  7. click READ (this will take ages - infact, with a 32gb card i think it would have been quicker repeating steps 1-7 if something went wrong....)


Step 9 - Resize partition

I got a 32gb card, the default image you applied in step 1 only uses 2gb of it and leaves the rest unpartitioned, to use that unpartitioned space:

  1. reboot & log back in
  2. df -h (note the volume size of your root volumes)
  3. sudo fdisk -uc /dev/mmcblk0 (take note of p2 start sector)
  4. p
  5. d (delete partition)
  6. 2 (partition 2)
  7. d
  8. 3
  9. n (New partition)
  10. p (of type primary)
  11. 2 (new partition number
  12. enter start sector noted in step 3)
  13. leave end sectore blank to use default
  14. w (saves all changes)
  15. reboot & log back in
  16. sudo resize2fs /dev/mmcblk0p2 (takes a while)
  17. df -h (to confirm new volume sizes)
  18. cd /var (switch dir)
  19. sudo dd if=/dev/zero of=swapfile bs=1M count=128 (takes a while)
  20. sudo mkswap /var/swapfile (takes a while)
  21. sudo swapon /var/swapfile (takes a while)
  22. reboot & log back in
  23. sudo nano /etc/fstab
  24. replace contents with this:

Download source  Code

proc            /proc   proc    defaults                        0 0
/dev/mmcblk0p1  /boot   vfat    defaults                        0 0
/dev/mmcblk0p2  /       ext4    defaults,noatime,nodiratime     0 0
/var/swapfile   none    swap    sw                              0 0




  1. reboot & log back in (df -h again if you want to confirm everything is OK)


Source: http://www.youtub...4VovMDnsIE

Step 10 - Apache time

This is pretty much a normal linux install using apt-get, first, update apt-get

  1. sudo apt-get update (takes a while & might finish advising you to run it a 2nd time, go ahead and do that)
  2. sudo apt-get apache2 (enter Y to confirm) (Takes a while - ignore the startup errors at the end)
  3. cd /etc/
  4. ls -l (note the new apache2 dir in the list)
  5. cd apache2 (to select that new folder & make sure it exists etc)
  6. cd /var/www/
  7. ls -l (just to check the www root folder has been created and the index.html file written)
  8. cd /etc/apache2
  9. sudo service apache2 start (this should give an error about a bad group name)
  10. sudo nano envvars
  11. locate lines:

Download source  Code

export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data




  1. Replace with: (if you're using putty you can highlight the existing lines then just right-click the selection to auto-copy/paste)

Download source  Code

# export APACHE_RUN_USER=www-data
# export APACHE_RUN_GROUP=www-data
export APACHE_RUN_USER=pi
export APACHE_RUN_GROUP=pi




  1. Hit Ctrl+X to exit, when prompted to save hit Y then Enter to confirm the filename
  2. sudo nano httpd.conf
  3. Add line:

Download source  Code

ServerName localhost




  1. Hit Ctrl+X to exit, when prompted to save hit Y then Enter to confirm the filename
  2. sudo service apache2 start
  3. hit a web browser on another pc and go to http://192.168.0.XXX
  4. Note: as default, all site files should go in /var/www)


Step 11 - Installing php5

  1. sudo apt-get install php5
  2. y (then wait a good while)
  3. php -v (just to check it installed & version)
  4. sudo service apache2 restart


Step 12 - Installing mysql

  1. sudo apt-get install mysql-server mysql-client
  2. sudo apt-get install php5-mysql
  3. sudo service apache2 restart


Step 13 - Installing phpmyadmin

apt-get wont work for the pi as it assumes a default group "www-data" that does not exist in the squeeze

Quickest way is to install manually:

  1. Download zip from http://www.phpmya.../index.php
  2. extract to your www folder (i used a sub folder called db)
  3. create a blank writable folder within the phpmyadmin folder called config
  4. Navigate to http://192.168.0.xxx/db/setup
  5. If it says that various php items are missing (mcrypt etc) install these as follows:

Download source  Code
sudo apt-get install php5-mcrypt



  1. Click "Add Database" and use the default localhost settings, click save.
  2. On the setup main screen, click the Save button again, this will write the finished config to the /config folder, move this into the root of db (or whatever you called your phpmyadmin folder)
  3. login with root / whatever mysql password you used when installing mysql


Step 14 - Installing webmin

This is easy:

  1. cd /etc/apt
  2. sudo nano sources.list (Add the following lines:)

Download source  Code
deb http://download.webmin.com/download/repository sarge contrib
deb http://webmin.mirror.somersettechsolutions.co.uk/repository sarge contrib



  1. cd
  2. wget http://www.webmin.com/jcameron-key.asc
  3. sudo apt-key add jcameron-key.asc
  4. sudo apt-get update (twice if needed)
  5. apt-get install webmin (takes a whilst as it needs to isntall pearl)


Job done
Edited by admin on 01-07-2012 23:19
Jordon Pilling | Heavencore Administrator
 
Jump to Forum: