Apache Web Server Raspberry Pi



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

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.

Install Apache

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

Then, install the apache2 package with this command:

Jun 09, 2019 Apache provides many powerful features that can be extended through additional modules. In this tutorial, we will explain how to install Apache Web server on Raspberry Pi. We’re assuming that you have Raspbian installed on your Raspberry Pi. Jurm movie song pk. Hotel arts calgary gym. Installing Apache #.

Test the web server

  • A personal web server is 'the cloud,' except you own and control it as opposed to a large corporation. Owning a little cloud has a lot of benefits, including customization, free storage, free Internet services, a path into open source software, high-quality security, full control over your content, the ability to make quick changes, a place to experiment with code, and much more.
  • If I run that command again, it will say that Apache is uninstalled. I've tried uninstalling all of these packages: apache2 php5 libapache2-mod-php5, but, whenever I reboot and go to my Pi's IP, I always get the Apache welcome file. I then thought that it would be an issue of another web server was handling the Apache.

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:

Web

Epson tx111 scanner driver. This will show you:

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.

Raspberry Pi Apache2

Raspberry

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:

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:

Further - WordPress

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

If you're feeling brave, you might want your Raspberry Pi powered web server to host more than one website or subdomain. Providing you've made the necessary modifications to increase performance, and are running Raspbian from a USB flash drive, there's no reason why your Raspberry Pi couldn't host more than one site.

Before you begin, I'm going to presume that you've followed my earlier tutorials to install Apache2, PHP and MySQL on your Raspberry Pi, and you have already got your domain or subdomain DNS records pointing to your Raspberry Pi.

Step 1 – Create the sites available file for your domain or subdomain

Throughout this tutorial, I'll be adding the subdomain video.dingleberrypi.com so replace this with your domain or subdomain you want to add. First, we'll run our usual sudo bash command to login at root level:

After we've done this, we'll want to copy the default file:

Raspberry pi website host

Now, we'll want to edit this file to tell Apache where the document root is, as well as any other information we wish to provide. To do this, type:

Apache Web Server Raspberry Pi

Once you've opened your file, we'll need to add a line. After the line ‘ServerAdmin [email protected]' (change this to your email address if you really want to), type the following line (edit as you see fit):

After this, we'll want to change the document root. Don't worry if the folder isn't there yet, we'll create it in the next step. Change the document root and directory to something similar to how I have b?resize=697%2C445&ssl=1)](/content/images/2013/08/nano.jpg?ssl=1)Make a note of the directory, we'll create it next. Now press CTRL + X to quit, and save when prompted.

Step 2 – Create the document root for your domain or subdomain

Next, we'll need to create and set the correct permissions to the document root. You can choose whatever path to use, but I'm creating mine inside a directory called vhosts inside the www folder.

If you've not already created the ‘vhosts' directory already, you'll need to create this first:

After this, create the site's directory:

If you've not already created the ‘vhosts' directory already, you'll need to create this first:

Almost there! Now we need to set the permissions so that the system can write, and everyone else can read:

Step 3 – Enable the subdomain or domain and restart Apache2

Next, we're going to use a built in extension to enable the submain or domain:

Now, it's time to restart apache:

Step 4 – Give it a try!

Raspberry Pi Php Server

Let's create a file in our site's directory to give it a go. Type the following command to create our index.php file:

Install Apache Web Server Raspberry Pi

Now type the following into?resize=695%2C448&ssl=1)](/content/images/2013/08/PHPinfo.jpg?ssl=1)

Give it a go, visit your subdomain and you should see the PHP info. Replace the index.php file with your subdomain or virtual host, and that's it. Just in case you wondered what video is on my video.dingleberrypi.com it's below!

Leave a comment below (or on the video if you really want to). Your feedback and thoughts always welcome!