Have a Question?
Table of Contents
< All Topics
Print

002 Install and Setup up Apache Web Server

Requirements:

Apache is a web server platform that is open-source and well-supported. by itself, it will host HTML-based web pages. You can also install server-side process programming languages like PHP. We will be using PHP for most of the web pages in Mission Control. More on that later.

Step 1: Update Raspberry Pi OS

sudo apt-get update
sudo apt-get upgrade

Step 2: Install Apache 2.0

sudo apt install apache2 -y

It’s a good idea to restart your Raspberry Pi.

sudo reboot

Apache is now installed. Let’s test it.

Determine the IP address of your Pi, if you don’t already know it.

ifconfig

You will see this. The number in yellow below is my IP address.

From your PC or Mac, open your web browser and browse to: HTTP://172.16.40.197

Note: you will replace the numbers with the IP address you found in ifconfig.

You should see the following page:

Creating a Hello World Page

Html files for apache are located in the /var/www/html folder. Type the follow to access that folder:

cd /var/www/html

From there, you can type LS to list the files in that folder.  You should see one file, index.html

ls

Let’s add a new file in that folder called hello.html and add some HTML code to display “Hello World”

sudo nano /var/www/html/hello.html

Once in the file type

<h1>
Hello World!
</h1>

To exit the nano text editor press control-x, then Y to save, then enter to accept the filename

To test your page head over to your PC or Mac and navigate to: HTTP://172.16.40.197/hello.html. Or whatever your IP address is.

You should see Hello World! in the header (h1) style

 

If hello.html worked for you, you successfully installed Apache on your Raspberry Pi.