Raspberry Pi Web Server




Hi there,
This is my first Instructable so all criticisms and comments are welcome.
This will show you how to set up a simple wired web server on your Raspberry Pi, with PHP and MySql.
Raspberry Pi Web Server
The Raspberry Pi is a good choice for a webserver that will not recieve too much traffic, such as a testing server, or small intranet, as it doesn;t get too hot (so is nice and quiet), and only uses around 5 Watts of power (costing £3.50 a year where I am if it’s running 24/7)

In the future I might add how to set up a wireless server.

If you have any problems, post them in the comments, or PM me – I’m happy to help.

Step 1: You will Need

To create a simple web server, you will need:

1. A power supply (Micro USB)
2. A network cable
3. A HDMI cable (or Component cable) as well as a screen and USB keyboard
3. A Raspberry Pi
4. An SD card (2GB or more)
5. An SD card reader for your computer
6. Win32DiskImager (For Windows) or dd (for Unix)
7. The Raspberry Pi Debian Image
8. PuTTY (For Windows) or any other SSH client
9. Around an hour of free time

You can download the software from the following locations:

http://www.softpedia.com/get/CD-DVD-Tools/Data-CD-DVD-Burning/Win32-Disk-Imager.shtml (for Win32DiskImager)
http://downloads.raspberrypi.org/download.php?file=/images/debian/6/debian6-19-04-2012/debian6-19-04-2012.zip (Debian Image)
http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html (for PuTTY)

Step 2: Format SD Card

Firstly, you need to install the Debian image onto an SD card (2GB or more).
(The image can be downloaded from http://downloads.raspberrypi.org/download.php?file=/images/debian/6/debian6-19-04-2012/debian6-19-04-2012.zip)

You can do this using the Win23DiskImager tool for Windows (downloaded from http://www.softpedia.com/get/CD-DVD-Tools/Data-CD-DVD-Burning/Win32-Disk-Imager.shtml)

Insert your SD card.
Once you have downloaded the above, Extract the Debian image, and the Imaging tool, then run Win32DiskImager.
Ignore the error that you will see.
Select the Image file (debian6-19-04-2012) and your SD card, then click “Write”, it will ask you to confirm, click “Yes”. Then enjoy a break, as it usually takes a couple of minutes to write.

Once the write process has finished, you can remove the SD card, then the fun begins.

Step 3: Allow SSH connectionsRaspberry Pi Web Server need

Now plug the HDMI cable into your Raspberry Pi and your monitor, then add the power cable and SD card, as well as the USB Keyboard.

When you first turn on your Raspberry Pi, the boot up might take a while, but be patient. It will also reboot itself once, this is normal.

Login with the following information when prompted:
Username: pi
Password: raspberry

Type in the following without the quote marks:

sudo -i
[Return / Enter key]
cd /boot
[Return / Enter key]
mv boot_enable_ssh.rc boot.rc
[Return / Enter key]
reboot
[Return / Enter key]

This will restart your raspberry pi.

Step 4: Change Hostname

Now that SSH is enabled, you want to change the hostname so you can connect to it more easily.

Login to your raspberry pi with the username pi and password raspberry.

Type in the following without the quote marks:

sudo -i
[Return / Enter key]
nano /etc/dhcp/dhclient.conf
[Return / Enter key]

Now look for the line “#send host-name “xxxxxx”;” (on mine, xxxxxx is andare.fugue.com), and remove the “#” symbol from in front of it.

Now hold the Ctrl key and press “x” to save the changes. You will be asked to save changes, just type “y” then hit the Return / Enter key.

Then type “hostname xxxxxx” where “xxxxxx” is what you want to call your server (I chose “raspberryPi” to make it easy).
Please Note that you cannot have any spaces in the hostname.

Finally for this step, type in “ifdown eth0” and hit Return / Enter.
Once that has finished, type “ifup eth0” and hit Return / Enter.

Now type “halt” and hit Return / Enter.

Step 5: SSH Login

Once your Raspberry Pi has halted, you can disconnect it from the monitor as it is no longer needed.

Plug your Raspberry Pi’s power connection in, as well as the network cable into your switch, or hub / router.
Wait a minute or so, then run your SSH client. (I used PuTTY).

Type your hostname into the hostname box, and use port 22. (The hostname is the one you set earlier).
Then click “Open“.

As this is the first time you have connected to your Raspberry Pi via SSH, you will get a security warning. Click “Yes” to continue.

Now you can login to your Raspberry Pi with the username: pi and password: raspberry.

Since SSH is working, you no longer need to worry about plugging in a monitor, or keyboard, so you Raspberry Pi can be placed anywhere where there are power and network connections available.

 

For more detail: Raspberry Pi Web Server


© 2015 Powered By Engineering Projects Team, Raspberry Pi Projects

Scroll to top