Raspberry Pi Webserver

Download (0)

Full text

(1)

Raspberry Pi Webserver

Max Runia

1

, Kanwalinderjit Gagneja

1 1

Department of Computer Science, Southern Oregon University, Ashland, OR, USA

Abstract - We used a Raspberry Pi to configure and set up a

webserver with an IP address and port forwarding, which would allow access from another source connected to a network. The webserver will have minimal features; we were focusing more on the development and configuration process with a very fundamental format that makes it easy to understand and simple to teach to someone who has little to no experience setting up and configuring a webserver with a Raspberry Pi. We end up using some basic SQL and a few fundamental Unix/Linux commands and some SSH since the webserver was setup on Linux and involved port forwarding from another computer.

Keywords: Raspberry Pi, apache, web server, Linux, code index;

1

Introduction

The raspberry pi was invented by Eben Upton. He invented it to help the kids learn the coding in a simpler way. Up to 5 million units of raspberry pi have been sold. This tiny computer is just $35 and is sparking a revolution. There is a large user community of Raspberry Pi, although, it was launched just recently on February, 29th 2012. The Pi enthusiasts are organizing community led events all over the world. Such events are full of learning for the kids to code.

We planned to use a Raspberry Pi to configure and set up a webserver with an IP address and port forwarding, which would allow access from another source connected to a network. The webserver will have minimal features; we were focusing more on the development and configuration process with a very fundamental format that makes it easy to understand and simple to teach to someone who has little to no experience setting up and configuring a webserver with a Raspberry Pi. We end up using some basic SQL and a few fundamental Unix/Linux commands and some SSH since the webserver was setup on Linux and involved port forwarding from another computer.

Now to elaborate on what a Raspberry Pi is, the Raspberry Pi is a credit-card-sized single-board computer developed in the UK by the Raspberry Pi Foundation with the intention of promoting the teaching of basic computer science in schools [6]. The Raspberry Pi sports a meager 256MB of RAM and a 700MHz ARM-11 processor. The Model B also contains two USB ports, an HDMI out and a 10/100 Ethernet port. For audio it possesses a 3.5mm audio jack, the HDMI output also supports audio transmission. The Raspberry Pi's GPU boasts 1 Gpixel/s, 1.5 Gtexel/s or 24 GFLOPs of general purpose compute power and is OpenGL 2.0 Compliant.

Nothing too fancy or complex, just a very simple machine meant for learning and is shown in figure 1.

Figure 1: Raspberry Pi

There is one daunting question ‘What could you do with such a small computer?’ The people are using it for various purposes. For example, Picade Arcade Cabinet has put it into practice like a arcade machine, which is very small but fully functional [2]. Another inventor used a weather ballon to put his camera attached with Raspberry Pi to the upper enviornment to record what all is happening underneath. One of the invertors used Raspberry Pi for streaming music, where it is being used as a very low-cost wireless music streaming equipment [5]. Another inovator prepared a Raspberry Pi Keyboard Computer. This innovation presents a complete computer packaged with a keyboard. One of the inovators used Raspberry Pi as a Bitcoin Miner and named it as ‘Pi-Powered Bitcoin Miner’. Therefore, this $35 tiny computer allows you to take part in mining of Bitcoin that can give you certain amount of monetary benefit [2].

The Raspberry Pi has a microcontroller. And this microcontroller’s functions depend on specific timing. However, the microcontroller is largely designed to work for one purpose only. Therefore there are not operating system overheads or there are no drivers’s to slow the system down. So, this microcontroller uses exceptionally detailed clock cycles to perform any task.

(2)

2

Process Followed

To begin the process of configuring a Raspberry Pi to work as webserver, an Operating System of a Linux Distribution, called Wheezy, specifically created for the Raspberry Pi, was downloaded onto an SD memory card with at least 4 GB of memory, via another computer, and inserted into the Raspberry PI [8]. Details of the completed installation can be viewed by opening the website [1] and logging in with the correct user credentials. A Windows Distribution or a Mac OS X can be installed instead, Linux was a personal preference.

The Raspberry PI is then connected to a power source through a micro USB power supply and an Ethernet network outlet and requires a monitor and keyboard to view and give the commands, since it is a Linux based OS we did not require a mouse. With the SD card inserted and the physical connections set up properly, a configuration window appears on first boot, called raspi-config, from there the Raspberry PI can then be setup through command prompts and an options menu, as shown on page 4 in figure 2.

You can alter the local time or time zone and enable ssh, as we did, but when you are finished you are going to select the second command prompt "expand_rootfs" and press enter. To put it simply, this will partition the OS of choice onto the entire space of the SD card. Afterwards you will reboot the Raspberry Pi by selecting “Finish” and pressing enter.

Now from here on there are many different methods to finish the configuration and installations of your Raspberry Pi to make it work as a webserver, we will stick to the methods we used to accomplish this, if you are interested in other methods they are easily found all over the internet. The rest can be accomplished through following simple instructions or tutorials online. Since we enabled ssh we were then able to use to finish the setup and installations from a laptop [7]. We used the cmd console to access the pi with ssh and used sudo and Linux bash commands [4] to finish the configurations and install apache webserver and php as shown in fig. 3.

These commands can be seen in the code appendix after the Conclusion section of the paper. Other OS’s on the Raspberry Pi may possess a GUI you can interact with directly from the Raspberry Pi, being a Linux OS we had to use the command console without any GUI.

Once the installation and configuration was finished we needed to obtain a domain name for the server. We went to noip.com [9] which allows us to use their domain name for free; otherwise we would have to purchase a domain name. With the noip domain name or server name is rasppiserver.no-ip.org, the noip domain name is highlighted for reference (fig 4.).

As mentioned earlier, we used port forwarding to access the Raspberry PI from another source; another computer, phone, etc. To do this, the source would have to attempt to gain access through the router where the Raspberry Pi is connected.

This can be accomplished by typing in the Public IP address 75.142.152.19 and either port 80, 21, 22, or 23 into the URL bar as so: 75.142.152.19:80. This will forward any traffic attempting to access the Public IP address towards the Local/Private IP address 192.168.1.6 of Raspberry PI, thus granting us remote access to the Raspberry Pi and its contents as shown in fig. 5.

2.1 Problems Faced

Over the course of the whole set up, we encountered a few problems. Each of which required a little research to solve. Following is a list of problems we encountered and a few screen shots of the solutions we used. Here we were having trouble getting phpmyadmin to show up at rasppiserver.noip.org/phpmyadmin [1]. To solve this problem we needed to make a short cut to phpmyadmin in the apache2.conf file, so that apache knew where to include it from. (Notice the last line added to the apache2.conf file as shown in fig 6.)

Another problem we came across was not being able to find a repository for the no-ip update program. First we tried to install it using sudo apt-get install no-ip2 but it was not available for the wheezy distribution. To solve this we had to download a tar file directly from the no-ip server and compile and install it ourselves. We used the command:

wget http://www.no-ip.com/client/linux/noip-duc-linux.tar.gz to download the tar file.

We were able to get the Raspberry Pi configured and set up with a Private IP address and port forwarding working. We can access the Raspberry Pi from any computer through port forwarding, using the local IP address of designated router and a specified port [3]. The results conclude that using a Raspberry Pi to configure a webserver is simple enough that mostly anyone could accomplish it in a number of different ways.

2.2 Lessons learnt

What we learnt from this work is how to configure a webserver through the use of a Raspberry Pi. We learned how port forwarding works with IP addresses. We gained some basic familiarization with sudo commands in Linux. It can also be acknowledged that webservers can host more than just html or php webpages. They can be used for file storage and organization among many more tasks with a number a uses. As mentioned before, this is not the only way to configure a Raspberry Pi, there are multiple procedures to accomplish the goal of creating a webserver with any design the owner would

(3)

prefer. Also, this is not the only way to set up a webserver in general, just a very fundamental method we used for this project; there exist many more complicated methods with varying methods and different results.

3

Conclusions

We were to setup a web server in very small budget. So we planned to use a Raspberry Pi to configure and set up a webserver with an IP address and port forwarding, which would allow access from another source connected to a network. In this case the given webserver has minimal features. The main focus is more on the development and configuration process with a very fundamental format that makes it easy to understand and simple to teach to someone who has little to no experience setting up and configuring a webserver with a Raspberry Pi. We used very basic SQL commands, some Linux fundamental commands, and some SSH.

Code Appendix

Here is a list of the commands that we used from the laptop through the command console after accessing the Raspberry Pi with ssh.

154 cd /etc/network 155 ls

156 sudo nano interfaces 157 more interfaces

(edit interfaces file to make local ip static ip: 192.168.1.6) 160 sudo apt-get install apache2 php5 libapache2-mod-php5 162 sudo service apache2 restart

(install apache and php)

164 sudo apt-get install mysql-server mysql-client php5-mysql

(install mysql)

171 sudo chown -R pi /var/www

(make user: pi the owner of /var/www -the root directory where all files go for the website hosted on our server)

172 sudo apt-get install vsftpd 173 sudo nano /etc/vsftpd.conf 174 sudo service vsftpd restart

(install and edit the ftp program)

177 sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin

(install phpMyAdmin)

181 sudo nano /etc/apache2/apache2.conf 182 sudo service apache2 restart

(edit the apache config file so that phpMyAdmin can be accessed) 193 mkdir /home/pi/noip 194 cd ~/noip 196 wget http://www.no-ip.com/client/linux/noip-duc-linux.tar.gz 197 tar vzxf noip-duc-linux.tar.gz 198 cd noip-2.1.9-1 199 sudo make 200 sudo make install

(install the noip update program) 202 sudo /usr/local/bin/noip2 (start the no-ip update program)

4

References

[1] rasppiserver.no-ip.org/phpmyadmin Last visited Feb. 2015.

[2] http://www.scribd.com/doc/255957808/Raspberry-Pi-for-Beginners-Revised. Last visited March 26th2015 [3] “Hacking Raspberry Pi” Timothy L. Warner, 2013. [4] http://www.openvisionnetworks.com/dev/Learn%20Ras

pberry%20Pi%20with%20Linux.pdf last visited March 26th2015.

[5] http://www.instructables.com/id/Raspberry-Pi-Projects/

Last visited April 3rd 2015. [6]

https://dev.windows.com/en-us/featured/raspberrypi2supportLast visited March 3rd 2015.

(4)

[8] “Learn Raspberry Pi with Linux”, Peter Membery and David Hows

[9] noip.org

Figure2: Raspi-config window, information about the tool

(5)

Figure 4:NO-IP free member portal

(6)

Figure

Figure 1: Raspberry Pi

Figure 1:

Raspberry Pi p.1
Figure 3: installing apache webserver and PHP

Figure 3:

installing apache webserver and PHP p.4
Figure 4:NO-IP free member portal

Figure 4:NO-IP

free member portal p.5
Figure 5: Virtual server working

Figure 5:

Virtual server working p.5
Figure 6: Modifications to apache.conf

Figure 6:

Modifications to apache.conf p.6

References