EEWeb Pulse - Volume 98

Page 24

EEWeb PULSE Click the image below to read Part 3 of the series:

Do so by inserting the lines reading:

127.0.0.1 localhost.localdomain localhost 1 localhost.localdomain localhost to be:

127.0.0.1 localhost.localdomain localhost webpi 1 localhost.localdomain localhost webpi To ensure your setup is complete, restart your Raspberry Pi, and then attempt to ping your hostname locally using the command ping webpi.

Note: Depending on the quality of your router, you may be able to skip this step. Try pinging webpi before editing your host file on your client machines If you haven’t already set up the “ sudo ” software and a separate non-root account on your Raspberry Pi, and you plan to have it accessible to the public on a network, I would recommend you do so. You don’t want people to have root access to your Raspberry Pi over the network; they could seriously mess with your setup or steal your files. There are plenty of good resources online for setting up sudo. A setup guide is available here for Debian. We’re using Arch Linux ARM, but the process is mostly the same (note: you have to use pacman on Arch instead of apt-get to install the software). Also, if you’re not familiar with command-line text editors like vi or nano, you can find many quick references online. One such reference for Vi is located here.

Hostname Setup You’ll need to define a hostname that you will use to refer to your Raspberry Pi Server. You’ll want to edit your hostname configuration file, located at /etc/hostname, using any text editor. For example you can use:

vi /etc/hostname

Now, get your local ip address by running the “ifconfig” command. It will most likely be of the form 192.168.XXX. XXX if you’re using a local home network. Make note of the ip address. If that is successful, hop onto another computer on the local network and attempt to ping the local IP address of the Raspberry Pi that you have noted down. If it works and you get a response, add that IP address to your hosts file on the machine you’d like to access the server from. If you’re using Windows, you want to edit C:/windows/ system32/etc/hosts, and on Linux you want to edit /etc/ hosts. Add the line:

<LOCALIP> webpi Try to ping again by using the “ ping webpi ” command. Hopefully it will work. If you’re stuck on this step, have a look at your router’s settings to make sure it isn’t interfering.

Apache Setup

You’ll then want to change the file to contain the name by which you want your Raspberry Pi known. In this example, my Raspberry Pi will be known as “webpi”. Any time you see the name “webpi” for the remainder of this article it should be replaced with whatever you’ve decided to call your server.

Now that we can access our Raspberry Pi on the network, we only need to setup a webserver to be able to serve web pages. A very common webserver is Apache. Install Apache on your Raspberry Pi by using pacman:

Once you edit the hostname, you should also edit the hosts file to let the Raspberry Pi know that it should refer to itself with that name. This time we want to edit /etc/hosts .

Before we start the webserver, we may want to configure Apache. To do so we must write the configuration files that Apache will use to run the server. Navigate to /etc/httpd/ conf. This is the folder that Apache stores it’s configuration files. We’ll want to edit httpd.conf, which is the main

You want to add 127.0.0.1 and ::1 as webpi.

24

pacman -S apache

EEWeb | Electrical Engineering Community


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.