RPi Apache2

Author's Comments
This is a guide to install the Apache HTTP Server "Apache" on the Raspberry Pi computer running Debian "squeeze". The core of this guide is a basic installation of Apache, configured to serve static HTML pages. The serving of dynamic HTML pages via additional software like PHP and Ruby on Rails is beyond the scope of this guide, although these instructions could be used as a foundation before installing those additional components.

The guide has been developed/tested using debian6-19-04-2012. A standard 2Gb image has enough room for this install, although you may want to use a larger image to give yourself a bit more elbow room on the already-cramped root folder. (Learn how to expand your image here or here.)  This guide requires a network connection.

The installation was all done from the basic (pre startx) command prompt.

Prep Work
A little Debian/Apache foreknowledge: The default Debian install of Apache will be configured to run in the "www-data" user space, and use the "www-data" group. The version of Debian used for this guide (debian6-19-04-2012) already includes the "www-data" user, but not the "www-data" group. The following commands will create the "www-data" group, and add the "www-data" user to the newly-created group: sudo addgroup www-data sudo adduser www-data www-data
 * 1) Create the www-data group

A touch more Debian/Apache foreknowledge: The default Debian install of Apache will be configured to serve HTML pages from the "/var/www" folder. While this folder is created during the Apache2 install process, it will likely be created with the wrong owner:group (root:root). We can ensure a smoother install and successful running of Apache2 by creating this folder ahead of time and changing owner:group to www-data:www-data. sudo mkdir /var/www sudo chown -R www-data:www-data /var/www
 * 1) Create the /var/www folder and reassign ownership of the folder (and any files/subfolders)

Install Apache2
Get the latest version of Apache2 from the Debian repository: sudo apt-get update sudo apt-get install apache2
 * 1) Update repository information
 * 1) Install Apache

The "apache2" package requires the installation of a slew of additional packages (often called "dependencies"). Press "Y", then "enter" (or just "enter", as "Y" is the default response), and sit back while the "apt-get" package manager does its thing. Towards the end of the install, you should see a few lines that look like this: Setting up apache2-mpm-worker (2.2.16-6+squeeze7) ... Starting web server: apache2apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName. Setting up apache2 (2.2.16-6+squeeze7) ... This is a sign of a successful install!

Check if the default home page was created
If the "/var/www" folder was created and ownership of the folder was reassigned to "www-data:www-data", then a new file should have been created during the install process: "/var/www/index.html". This is the default page of your website. The following command should display the following text: cat /var/www/index.html Output from the previous command: It works! This is the default web page for this server. The web server software is running but no content has been added, yet.
 * 1) Display the contents of our site's home page

Testing Installation
You should now have an operational Apache2 web server! There are a few ways to test this:

command line
wget http://localhost/ ~/ cat /var/www/index.html cat ~/index.html
 * 1) Use a basic Internet tool to download the web server's starting page
 * 1) Use your eyeballs to compare the source file with the downloaded file

GUI (untested)
http://localhost/ It works! This is the default web page for this server. The web server software is running but no content has been added, yet.
 * Open the web browser (probably Midori)
 * Browse to the following URL:
 * You should see the following text (except with a bit more formatting):

From another computer, using a web browser
ifconfig eth0 eth0     Link encap:Ethernet  HWaddr b8:27:eb:9b:03:55 inet addr:192.168.2.123 Bcast:192.168.2.255  Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1488  Metric:1 RX packets:17360 errors:0 dropped:0 overruns:0 frame:0 TX packets:4789 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:11645538 (11.1 MiB) TX bytes:443716 (433.3 KiB)
 * Get the web server's IP address
 * 1) Sample output from the previous "ifconfig eth0" command


 * The IP address of the default network card is listed after the "inet addr:" title. (In my example above, the IP address of my web server is "192.168.2.123".  Write down the IP address of your web server - you're going to use it during the next step

http:///
 * Browse the web server from another computer using a GUI
 * Open the web browser
 * Browse to the following URL:
 * You should see the following text (except with a bit more formatting):

It works! This is the default web page for this server. The web server software is running but no content has been added, yet.

Specify Your Timezone
It is a good idea to have your web server's internal clock synchronized with the rest of the world. Specify your timezone.

Assign A Static IP Address
Specifying a static IP address will make it easier for you to access your web server from other computers.

Configure The SSH Daemon
Speaking of accessing your web server from other computers, adding the SSH daemon to the boot process will allow you to remotely log in to your web server as though you were sitting in front of it. Here's the code to have the SSH daemon autorun when the computer boots up: sudo update-rc.d ssh defaults If the SSH daemon is not already running, you can start it with the following command: sudo service ssh start Once the SSH daemon is running, you can remotely connect to your web server with the following command (substituting your server's IP address and your user account, where appropriate): ssh pi@192.168.2.123
 * 1) Add the SSH daemon to the startup script
 * 1) Start the SSH daemon
 * 1) Remotely connect to another computer via SSH

Troubleshooting
...