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 cover
I 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 Started
Current 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
Open Putty
- 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 pi@192.168.40.20's password: type "raspberry" press Enter.
Download and build our nginx package
We 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.
- Type "cd /tmp". press Enter. We are moving into our root temp directory to build our packages in.
- Type "sudo apt-get build-dep nginx". press Enter. This will download all dependencies for nginx.
- Type "sudo apt-get source nginx". press Enter. This will download the source for nginx.
- Type "cd /tmp/nginx-1.4.1 && sudo dpkg-buildpackage -uc -b". press Enter. This process will take a seriously long time. It is building the full install package.
Install our built package
We 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 Issues
Fail 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"
Excellent article, thanks for posting!
ReplyDeleteI think this tutorial might be useful as well:
ReplyDeletehttp://blog.szulak.net/administration/install-nginx-on-rhel-centos6/
Thank you for this posting! I just used it to install nginx-1.4.4 on a current Raspbian and only needed minor changes. I posted here:
ReplyDeletehttp://www.raspberrypi.org/phpBB3/viewtopic.php?f=50&t=48550&p=500185#p500185