Skip to main content
ApacheLPI Linux EssentialsRaspberry Pi

Installing an Apache Web Server on the Raspberry Pi

By May 7, 2014September 12th, 2022No Comments

Of course we have server applications as well as those for the desktop. The Linux Professional Institute understand that the Apache Web Server, their HTTPD product, is the most common web server you will find. We, of course, include this simple tutorial there for you to learn and enjoy.

The Importance of Omnipotence

Adding the Apache HTTP server to the Raspberry Pi will enable the tiny device to serve web content to local or internet users. You can imagine using the Raspberry Pi with online documentation that you make available though the web server. Even if this just to you and your office or home. The web server may also reach out to run other scripts and the web server may be the front-end graphical interface that you supply to control your pet robot or home heating. A web server is omnipotent.

Installing the Apache Web Server

To install the web server on the Pi:

sudo apt-get update
sudo apt-get install apache2

Once installed the packaging script will configure apache for autostart and start the service. Autostart just means that the server will start when the Raspberry Pi boots up. With the web server installed and running we should be able to browse to your site from the desktop of the Pi using the name localhost. Starting your Web browser, midori or another browser of you choice like Iceweasel we can enter the URL:

http://localhost

This should work or we can use the 127 IP address of the local system:

http://127.0.0.1

If you want to connect from another system on your network you will need to know the real IP Address the system has set. To discover this you can run the command as shown:

ip address show

On my system my address is 192.168.0.5. Look for the address assigned to the wired card eth0 or the wireless network card if connected.

http://192.168.0.5

The standard Apache welcome page will display display “It Works”. If we want we can then replace this page with one of our own making. The page is located on the Pi as /var/www/index.html. This is a text file and can be edited from the command line with nano or in the GUI using the Leaf editor,