Raspberry Pi Web Server Apache

Posted on  by 



Apache is a popular web server application you can install on the Raspberry Pi to allow it to serve web pages.

  1. Raspberry Pi Webcam Server
  2. Raspberry Pi As Web Server
  3. Raspberry Pi Web Server Apache Download
  4. Install Apache Web Server Raspberry Pi
Server

On its own, Apache can serve HTML files over HTTP, and with additional modules can serve dynamic web pages using scripting languages such as PHP.

Before we discuss http.server, let’s assumed that we have a little python script simplegpio.py that read Raspberry Pi’s GPU temperature from the Raspberry Pi, and it also control an LED connected to the Raspberry Pi. Just like every new Raspberry Pi user has experienced when they got their Raspberry Pi the fist time. What Is Apache Web Server? Apache is one of the most popular web server applications in the world, accounting for almost 40 percent of all web servers at the time of writing. Once you’ve set up Apache on your Raspberry Pi, you can use it to serve various files to anyone on the local network. Set up Apache Web Server on a Raspberry Pi STEP-01: Install the OS. Hook up the keyboard and mouse to the Pi and connect it to an HDMI monitor. Copy NOOBS to a. STEP-02: Check the network address. Make a note of the ‘inet addr’ value for eth0. This will be the IP address of your. STEP-03: Update. A simple command for this on raspbian is update-rc.d apache2 disable If you later want the webserver starts again on default just type update-rc.d apache2 enable ' With the comand sudo /etc/init.d/apache2 start you bring up the web server on demand.

Install Apache

First, update the available packages by typing the following command into the Terminal:

Then, install the apache2 package with this command:

Test the web server

By default, Apache puts a test HTML file in the web folder. This default web page is served when you browse to http://localhost/ on the Pi itself, or http://192.168.1.10 (whatever the Pi's IP address is) from another computer on the network. To find the Pi's IP address, type hostname -I at the command line (or read more about finding your IP address).

Browse to the default web page either on the Pi or from another computer on the network and you should see the following:

This means you have Apache working!

Changing the default web page

This default web page is just an HTML file on the filesystem. It is located at /var/www/html/index.html.

Navigate to this directory in a terminal window and have a look at what's inside:

This will show you:

Raspberry Pi Web Server Apache

Raspberry Pi Webcam Server

This shows that by default there is one file in /var/www/html/ called index.htmland it is owned by the root user (as is the enclosing folder). In order to edit the file, you need to change its ownership to your own username. Change the owner of the file (the default pi user is assumed here) using sudo chown pi: index.html.

You can now try editing this file and then refreshing the browser to see the web page change.

Your own website

If you know HTML you can put your own HTML files and other assets in this directory and serve them as a website on your local network.

Additional - install PHP

To allow your Apache server to process PHP files, you'll need to install the latest version of PHP and the PHP module for Apache. Type the following command to install these:

Now remove the index.html file:

Raspberry Pi As Web Server

and create the file index.php:

Put some PHP content in it:

Now save and refresh your browser. You should see 'hello world'. This is not dynamic but still served by PHP. Try something dynamic:

or show your PHP info:

Raspberry Pi Web Server Apache Download

Further - WordPress

Install Apache Web Server Raspberry Pi

Now you have Apache and PHP installed you can progress to setting up a WordPress site on your Pi. Continue to WordPress usage.





Coments are closed