Lets start off with why we need to get the latest update to ngnix.
- Current build of nginx from the Raspbian mirror for Raspberry Pi is out of date.
- Current "apt-get install nginx" has critical vulnerabilities.
What I am planning to coverI will cover more than just installing nginx into your RPi.
- Setting Static IP to your RPi
- Connecting to your RPi via SSH
- Getting the source files for compiling your newer nginx 1.4.1
- Compiling and building a package for using nginx source.
- Installing your built package into RPi
Getting StartedCurrent overview of my configuration. Using an 8Gig SDCard. I downloaded these items.
- You will need Win32DiskImager to put the image on your SDCard.
- I used Debian Wheezy for my Raspberry Pi Download Debian Wheezy. build 2013-02-09-wheezy-raspbian.zip.
Setting Static IP
First off you will probably want to set a static IP address to your RPi for your web service and this will aid the connection for SSH later.We will start using the built-in GUI for this basic task then move on to SSH.
- Open LXTerminal at the prompt type pi@raspberrypi ~ $ sudo nano /etc/network/interfaces
- Edit line "iface eth0 inet dhcp" change line to "iface eth0 inet static"
- Add these lines below "iface eth0 inet static"
- address 192.168.40.20 # This is your ip static address for you RPi
- netmask 255.255.255.0
- network 192.168.40.0
- broadcast 192.168.40.255
- gateway 192.168.40.1 # This assumes your gateway (router) to the internet is at .1
Here is our output now press ctrl+o then press Enter to save the file. Then press ctrl+x to exit.
At the console prompt type "sudo reboot" now while our RPi is rebooting lets get our SSH client (Putty) software. Download Putty here
Connecting to RPi via SSH
- In the Host Name (or IP address) enter your IP address example: 192.168.40.20 or whatever you gave your RPi.
- Under Saved Sessions type RPi and click Save.
- You will now have faster access to your RPi via SSH. Click Open.
- You will now be prompted for Login as: type "pi" press Enter. At firstname.lastname@example.org's password: type "raspberry" press Enter.
Download and build our nginx packageWe are going to setup our environment to take our new packages and have it build our packages.
- Type "cd /etc/apt". press Enter. We are going to add the source download location.
- Type "sudo nano sources.list". press Enter. We have to add lines here for the source.
- On a new line enter these lines.
- Type "deb http://nginx.org/packages/debian/ squeeze nginx". press Enter.
- Type "deb-src "http://nginx.org/packages/debian/ squeeze nginx"
- Type "ctrl+o then ctrl+x to save the file.
Install our built packageWe have now come a long way to get exactly what you need to get a current version of nginx build for your Raspberry Pi. Lets finish the with a quick install.
- Stop the exiting service! Type "sudo service nginx stop". press Enter.
- Remove previous package nginx if it exists Type "sudo apt-get remove nginx". press Enter
- Review the data in the package Type "dpkg-deb -I /tmp/nginx_1.4.1-1~squeeze_armhf.deb". press Enter.
- To instal the package Type "sudo dpkg -i /tmp/nginx_1.4.1-1~squeeze_armhf.deb". press Enter (If this fails see the known issues section.)
- Type "sudo reboot"
Known IssuesFail to install stating previous install files still exist.
- The not so graceful way Type "sudo dpkg -i --force-overwrite /tmp/nginx_1.4.1-1~squeeze_armhf.deb"