Apache

This service is really useful and can be used for all sorts of different things; it can display all sorts of info about your Pi, security system, or maybe just for fun!

1. Update/Upgrade your system!

sudo apt-get update

sudo apt-get upgrade

2. Install Apache

sudo apt-get install apache2

All done! It will start running after the installation, but to stop/start it use:

sudo service apache2 start

sudo service apache2 stop

You might get an error like: “Could not determine the server’s fully qualified domain name, using 127.0.X.1 for ServerName”

To fix this you need to get hold of your RPi’s IP address:

ifconfig

You need the digits directly after:

inet addr:

E.g. 192.xxx.x.xxx (note your numbers down!)

Now edit /etc/hostname:

sudo nano /etc/hostname

Look for the line “raspberrypi” and change it to a name of your choice, e.g. mybestpi

Save and close that file.

Now edit /etc/hosts:

sudo nano /etc/hosts

Add these to it (the first maybe already there, just commented – uncomment it):

127.0.0.1 localhost

10.0.0.97 localhost

10.0.0.97 mybestpi

Make sure you change ‘mybestpi’ to the name you chose for your box! Now, you remember that string of digits you noted down? Put them in place of “10.0.0.97” in both instances.

Save and close the file.

Now create a file in /etc/apache2/conf.d/.

sudo nano servername.conf

Look for the line “ServerName”

Put this into it (replacing ‘mybestpi’ with your name!), note that it’s a ‘tab’ in between the two blocks of text – not a space!:

ServerName mybestpi

Save and close the file.

Now restart Apache:

sudo service apache2 restart

Now, to test if it works, get up a browser on another machine and go to http://mybestpi

(Obviously replace ‘mybestpi’ with your name!!)

You should see “It works” displayed on you browser!

3. Add some files to your server!

You don’t really want only a page that says “It works” do you?

Edit the file!:

sudo nano /var/www/index.html

I suggest maybe putting in:

<html>
<head>
<title>Home | YourPi</title>
</head>

<body bgcolor=’grey’>

<p align=center>

<font size=’5′ color=’green’>
My site is quite hard to find, I bet you’re feeling brilliant now!
</font>

</p>

<style type=”text/css”>
#footer {
position: absolute;
bottom: 0;
color: purple
}
</style>

<div id=”footer”>I learnt how to make this site from <a href=”http://www.finniananderson.wordpress.com”>Finnian</a></div&gt;

</body>
</html>

Save and close the file!

🙂

All done, don’t forget you don’t have to keep the page I gave you the code for!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s