Raspberry Pi 2

My first exposure to a Raspberry Pi was fun, but kind of useless for web applications because of its slow speed.  Then recently they came out with the Pi 2 which is supposed to be 6 times faster or so.  I ordered one and it arrived today.  So far it seems much better than the old version, running web pages at a decent enough speed that “maybe” this could be used as a web server.  Here are my setup notes:

 Purchased

CanaKit Raspberry Pi 2 (1GB) Basic Kit with 2.5A Micro USB Power Supply
SanDisk Ultra 32GB UHI-I/Class 10 Micro SDHC Memory Card Up to 48MB/s

 OS Installation

I was thinking about trying Pidora, which would be Redhat for Pi, but it hasn’t been updated in about a year, so let’s go with Raspian as I did before.  My Windows 8 laptap has an SD port, and the mini SD required for the Raspi comes with an adapter.  So let’s use Win 8 for this.

Downloading

Download from http://downloads.raspberrypi.org/raspbian_latest (takes a long time) and unzip. Go to http://www.raspberrypi.org/documentation/installation/installing-images/windows.md for instructions.

Creating SD Disk Image

he zip file unzips to an img file that can be written to an SD drive (plugged into laptop SD port) using Win32DiskImage (free software).

** Note that the mini SD drive adapter has a slider on it for write protection. This kept switching itself to “protected” simply by sliding the adapter into the PC slot, until I added some tape to hold it in the “unprotected” position. Does not work well.

Booting the first time

I connected the following to the Raspberry:

  • HDMI cable directly to my TV set
  • USB Keyboard
  • 32G Mini SD Card (no adapter)
  • Power supply (2.5A USB)
  • Ethernet cord to my 8 channel switch

Run through the following options on the screen that appears:

  • Expand the filesystem
  • Change default password
  • Set the time zone to en_US ISO-8859-1

Then Finish and it will reboot.
Logon as userid pi using the password you just set. pi has sudo root authority.

The netstat -all command shows our IP as 192.168.xxx.xxx, so let’s keep that and set the router DHCP to always use that IP for this MAC address.

And we can connect to SSH now, so we can shut down HDMI to the TV set and just work through ssh. Since this server is called (by default) “raspberrypi”, let’s add a DNS name for that to my /etc/hosts file on Windows.

Software Updates

sudo su -
apt-get update
apt-get upgrade
apt-get dist-upgrade
shutdown -r now

Web Services

apt-get install apache2
apt-get install mysql-server <<– note asks for root mysql password as part of install process
apt-get install php5 php-pear php5-mysql
service apache2 restart
useradd -u 5010 -d /var/www webdoc
chown -R webdoc:webdoc /var/www
su – webdoc
vi /var/www/phpinfo.php <<– add phpinfo() call to test php installation

Then we can open a browser on my Windows PC and test www.rasberrypi.com/phpinfo.php which should show a nice display of php options.

Now, I want to enable the use of .htaccess in various directories on the server, but by default these are ignored with this apache2 installation.  Turns out /etc/apache2/apache2.conf has an Include statement for subdirectory “sites-enabled”, which is where file 000-default is located.  That file contains the Directory blocks that we need to modify by changing AuthOverride None to AuthOverride AuthConfig.  This is a bit unusual, but I assume they use this Include method so the main conf file is not so big.  However, like any Include, it becomes more difficult to maintain.

vi /etc/apache2/sites-enabled/000-default
service apache2 restart

Samba

apt-get install samba samba-common libcups2

Edit the following after making a backup, to setup samba as needed:
vi /etc/samba/smb.conf

Now you should be able to Map the R: drive to the server and do some work from Windows.

PHPMyAdmin

Use Windows file manager to copy phpmyadmin from existing server drive L: to drive R:
cd /var/www/phpmyadmin
vi config.inc.php

Performance

I haven’t created any web applications yet, but phpmyadmin performance seems reasonable.  Much much faster than on the Raspberry Pi B+ (old version).

So far so good!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>