[vc_row][vc_column width=”2/3″][vc_separator][venera_framed_image content_type=”video” css_animation=”appear” frame_type=”browser” slider_engine=”flexslider” video_link=”https://www.youtube.com/watch?v=WgcNBjIJNYs” browser_url=”https://www.youtube.com/watch?v=WgcNBjIJNYs”][vc_separator][/vc_column][vc_column width=”1/3″][/vc_column][/vc_row][vc_row][vc_column width=”2/3″][vc_tabs][vc_tab title=”About This Project” tab_id=”1402713028-1-39e9a4-2f88123b-77946048-9294ef23-7cf7″][vc_column_text]
The Raspberry Pi is an amazing $35 mini-computer. And in this video, I’ll show you how to set it up as a fully functioning web server.
[/vc_column_text][/vc_tab][vc_tab title=”Code” tab_id=”1402753910272-3-8123b-77946048-9294ef23-7cf7″][vc_column_text]
What is a Raspberry Pi
The Raspberry Pi is a revolutionary mini-computing system that is super cheap. It’s based on the ARM processor, and can be powered through USB (5v) and has all of the standard functionality of regular computers.
There are two types of Raspberry Pi Models: Model A ($25) and Model B ($35). Both models have 256mb of RAM, HDMI and Composite video connections, audio connections, USB power input, USB port output, and SD card input. Model B adds an ethernet port (for network connections) and an extra USB port, which is what makes it more expensive.
Since the Raspberry Pi is in such high demand, attaining one is kind of difficult. At the time of writing this wiki, you can only sign up to be notified when more Raspberry Pi devices are available. You can sign up at Alliedelec (North America only), RS-Online (everyone), or Element14 (everyone).
How To Set Up A Raspberry Pi
When you first receive a Raspberry Pi, it’s basically just a circuit board in a box. Obviously to run it as a computer, you need some necessary hardware peripherals first. Here’s the list of parts you will need to run it for the first time:
- A USB keyboard
- An HDMI or Composite cable
- A TV or Monitor that is HDMI or Composite capable
- A micro-usb power cable
- A 2gb or larger SD card (by default, the operating system can only access 2GB)
- A network cable (if you want to connect to the network)
Installing the Operating System
Before you can use the Raspberry pi, you have to install the Raspberry Pi Operating System on to the SD card. Don’t worry, it’s not as difficult as it sounds. If you have Windows (you can find Linux and Mac instructions here, there are only 2 things you need to download
- The Raspberry Pi Operating System (I chose the “Debian Squeeze” version)
- Win32DiskImager (The binary version)
Unzip the Debian Squeeze file that you downloaded. It should produce an ISO file. Now insert your SD card into the computer that you downloaded the files to. Open up Win32DiskImager and for the Device, choose the drive letter of you your SD card. Then click on the folder icon to browser to the Debian Squeeze ISO file that you downloaded. Lastly, click “Write” to write the image file to your SD card. It can take a few minutes to write the files.
Running For the First Time
Once the SD card has been prepped, stick it into your Raspberry Pi. Now you can start plugging in all of your other hardware peripherals, making sure to plug in the micro-usb cable last, since it provides the power.
Once power has been provided, you should start seeing the loading screen for the Raspberry Pi OS on your monitor. The first time, it will take a few minutes to completely load. All other times, it should load pretty fast. You’ll know when it’s through loading because you will see a line that says “raspberry pi login:”. The defaul login name is pi. And the default password is raspberry.
You should now be at a line that says pi@raspberrypi:~$. This means you can start entering in commands. For those of you that are used to a desktop environment, I know this isn’t what you had in mind. So if you prefer a desktop environment, you can type
startx
This will load the desktop environment. From here you can plug in a mouse and use it like you would a normal computer GUI.
Initial Software Setup
It’s good practice to update the software and software repositories when you first set up your Raspberry Pi. It’s also important to update the system clock via the internet, since the Raspberry Pi does not have real-time clock. So here’s a list of initial commands to get your system updated:
Configure Time
sudo dpkg-reconfigure tzdata
Update software packages
sudo apt-get update
Update Debian
sudo apt-get upgrade
Updating Firmware
NOTE: If you are running the latest Raspbian hard float release, this update tool will prevent your pi from booting. Only use this if you have Debian squeeze
To keep the Raspberry Pi firmware up-to-date, you have to install a program called Hexxeh’s RPI update tool through Git-hub. Here’s the process
Install certificate authority certificates
sudo apt-get install ca-certificates
Install Git (required to run Hexxeh)
sudo apt-get install git-core
Download Hexxeh’s RPI update tool
sudo wget http://goo.gl/1BOfJ -O /usr/bin/rpi-update && chmod +x /usr/bin/rpi-update
Update the firmware
sudo rpi-update
Reboot
sudo shutdown -r now
Setting Up SSH and Remote Connections
You will not have to do this step if you have downloaded Raspbian or Debian Wheezy – SSH should be enabled by default. If it is not enabled, follow these instructions:
To start out, type this then hit enter:
sudo raspi-config
You will now see a screen with a few options. Use the arrows keys to navigate to the SSH option. This will take you to another screen that asks you “Would you like the SSH server enabled or disabled?” Choose the <Enable> option with your arrow keys and hit enter. Select okay, and hit enter. Now, back at the raspi-config screen, navigate to <Finish> and hit enter. You should now be able to use SSH with your Pi!
An ideal setup of Raspberry Pi would be to control it remotely. This can be done through an SSH connection, but by default SSH connections are disabled. Before we enable it, the screen should have the IP address of the Raspberry Pi listed (ex. 192.168.2.37). Write down that IP address as we will need it for the SSH connection. Ok, To enable SSH, simply run this command:
sudo mv /boot/boot_enable_ssh.rc /boot/boot.rc
sudo shutdown -r now
Once the Raspberry Pi reboots, you can now unplug the keyboard and the monitor connections from the Raspberry Pi, as we will no longer need them for the rest of this tutorial.
On a remote Windows machine, in order to connect to the Raspberry Pi, you will need to download Putty, a Windows SSH client. Once it’s downloaded, start it up and type in the Raspberry Pi’s IP address that you wrote down earlier in the Host Name (or IP address) field. Then just click “open”. If it’s your first time connecting, Putty will ask you to store a key authentication, so click “Yes”. Now you should see a login screen where you can log in using your Raspberry Pi login credentials.
Changing the Password
For obvious security reasons, it’s recommended to change the default password to a secure password of your own. After you have logged into your pi account, to change the password, type:
sudo passwd pi
Now you should be prompted to enter in a new password. Once you’ve typed in your password and hit enter, you’ll then be prompted to repeat your password. After typing it in again and hitting enter, you will have successfully changed your password.
Installing the Server
In order to use the Raspberry Pi as a web server, you have to install all the necessary server software components. If you just want a simple HTML server, you can just install that server software (Apache or Cherokee). If you want MySQL and PHP support on your server, you have to install those components separately as well.
Apache Server
Apache server software is the most widely used server software. However, it is a little bit more bloated than the Cherokee server software. If you want a more traditional experience, you can install Apache. Otherwise, you can skip to the Cherokee Server section and install Cherokee. Here’s how to install Apache:
Install Apache with PHP
sudo apt-get install apache2 php5 libapache2-mod-php5
When it asks if you want to continue, press y
Resolve installation error
sudo groupadd www-data
sudo usermod -g www-data www-data
Restart Apache
sudo service apache2 restart
Now if you open up a web browser and type in your Raspberry Pi’s IP address, you should be pull up a the test page for your server!
Cherokee Server
If you want a lighter web server, then Cherokee is better than Apache. And considering the limited resources of the Raspberry Pi, lighter is better. Here’s how to install it:
Prevent install errors
sudo addgroup www-data
Install Cherokee
sudo apt-get install cherokee
Install PHP
sudo apt-get install php5-cgi
Edit the PHP config file
sudo nano /etc/php5/cgi/php.ini
Hit ctrl+W and search for cgi.fix_pathinfo=1, remove the ; form the front of the line
Hit ctrl+X to exit, y to save and enter to confirm
Restart Cherokee
/etc/init.d/cherokee restart
Now if you open up a web browser and type in your Raspberry Pi’s IP address, you should be pull up a the test page for your server!
Installing MySQL
Installing MySQL is pretty simple. You basically just install these packages:
sudo apt-get install mysql-server mysql-client php5-mysql
When it asks if you want to continue, press y
It will eventually prompt you for a new root user password, so create a strong password and continue until the installation is through.
Installing FTP
FTP is not only a great way to remotely add/change files on your website, but it’s also a great way to transfer files to your Raspberry Pi. This is important for installing PHP MyAdmin in the next step. These instructions are for the Apache server install.
Take ownership of the WWW Apache folder
sudo chown -R pi /var/www
Install VSFTP
sudo apt-get install vsftpd
Edit the FTP configuration file
sudo nano /etc/vsftpd.conf
Hit ctrl+W and search for anonymous_enable=YES, and change it to anonymous_enable=NO
Remove the # from in front of local_enable=YES
Remove the # from in front of write_enable=YES
Skip to the bottom of the file and add force_dot_files=YES
Hit ctrl+X to exit, y to save and enter to confirm
Restart VSFTP
sudo service vsftpd restart
Change the root users password
sudo passwd root
Create a new password and then exit out of Putty
exit
Restart Putty and log in as root with the new password
Edit the password configuration file
sudo nano /etc/passwd
Find the line pi:x;1000:1000:Raspberry Pi User,,,:home/pi:/bin/bash and add a # sign to the beginning of it.
Hit ctrl+X to exit, y to save and enter to confirm
Add the pi user as a mod and exit out of the Putty
sudo usermod -d /var/www pi
exit
Restart Putty and log in as pi
Give mod rights to root and exit
sudo usermod -L root
exit
Now your FTP server should be up and running. You can test it out by logging into it with any FTP client such as FileZilla or WinSCP. Use the IP address from your Raspberry Pi that you wrote down earlier, port 22, your Raspberry Pi username (pi), and your password.
Installing PHP MyAdmin
To better manage MySQL databases, it’s often preferred to use the PHP MyAdmin program. So here’s how you can install it:
- Download PHP MyAdmin
- Extract the zip file to a folder
- Using your FTP client upload the extracted PHP MyAdmin files to your web server.
To access PHP MyAdmin, in a web browser type in your Raspberry Pi’s IP address and then add /admin to the end of it (ex. 192.168.2.37/admin). Then you can log in using the root username and password that you created for your MySQL installation.
[/vc_column_text][/vc_tab][vc_tab title=”Important Links” tab_id=”1402753981900-3-10123b-77946048-9294ef23-7cf7″][vc_column_text]
Raspberry Pi – http://www.raspberrypi.org
Raspberry Pi Disk Image – http://www.raspberrypi.org/downloads
Win32DiskImager – https://launchpad.net/win32-image-writer
Putty – http://www.chiark.greenend.org.uk/~sgtatham/putty/
Website Tutorials – http://www.youtube.com/playlist?list=PL6291918FE7103470
Port Forwarding Tutorial – http://www.youtube.com/watch?v=1DSDbvtVIaA
Help support my channel: http://www.patreon.com/tinkernut Follow Tinkernut! Google + Facebook Twitter
[/vc_column_text][/vc_tab][/vc_tabs][/vc_column][vc_column width=”1/3″][/vc_column][/vc_row]