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://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 https://www.softpedia.com/get/System/Boot-Manager-Disk/Debian-Installer-Loader.shtml

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.


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter
Scroll to Top