Home / All / Make a Apache Server Using Raspberry Pi .
Raspberry Pi

Make a Apache Server Using Raspberry Pi .

Never underestimate the miniscule, $35 Raspberry Pi. Although it’s marketed as an experimental machine aimed at helping you learn to code, there’s nothing entry-level about its capabilities.

You could use your raspberry pi to host small php websites and web apps. For that you need to simply setup a Apache web server.

Getting Started 

1.) Router – You would need a router and a internet connection from ISP. If you have a static IP that would be too good.

2.) Connecting Pi to Network – You need to have a wireless adapter or an ethernet cable to connect your Pi to router.

3.) Raspbian O.S –  I would recommend using Raspbian Wheezy OS which could be downloaded from here.

4.) Setting Up SSH – You need to setup SSH on Pi . You could see my tutorial for that here.

Updating Your Pi. 

1.) SSH into your Pi Using Putty ( Windows ) . ‘

2.) Simply type – sudo apt-get update && sudo apt-get upgradeUpdating Pi .

Installing Nginx Web Server

1.) First install the nginx package .

2.) Type : sudo apt-get install nginx

3.) Then create a new directory for web apps that is the  root directory .

4.) Type : sudo mkdir /var/www 

5.) Now type sudo nano /etc/nginx/sites-available/default to edit the file. 

6.) Find this part and make the changes accordingly as shown.
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.

server {
#listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default_server ipv6only=on; ## listen for ipv6
listen 80;
server_name $domain_name;
root /var/www;
index index.html index.htm;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

# Make site accessible from http://localhost/
server_name localhost;

location /

Testing Nginx

1.) Create a file called index.html 

For that type in : sudo nano /var/www/index.html

And create a sample page –

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML+RDFa 1.1//EN">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Raspberry Web Server</title>
<p><h1 align="center">Welcome,<br />... your Raspberry Web Server is ready!! </h1>

restart nginx

sudo service nginx restart

Now enter the IP Address Of your Pi into web browser.

About Abdul Hannan Mustajab

Well hello there! Not wanting to keep myself obscure,here's something about me. WHO AM I? Im a young 17 year old,based in India. Currently pursuing education in the science - math stream , im an Computer Science aspirator. WHAT DO I LIKE? A simple statement says it all, computers & tech. WHAT DO I KNOW? I have a passion for programming and have learned the following programming languages so far - C,python,PHP & angular js. Also do I possess knowledge regarding web servers and linux and shell related stuff. WHAT ARE MY INTERESTS? Im interested in Raspberry pi & Arduino associated home automation and well that's what my website is about!

Check Also

Setup Instagram AutoLiker Bot On Raspberry Pi

  Do you have a instagram account and you wish to have thousands of followers …

Leave a Reply