Installing Rasperian & Apache webserver on raspberry pi from scratch


As you may already know NOOBS Raspberry Pi is the newest way of getting a suitable operating system onto If you have not purchased a NOOBS (New Out Of the Box Software) SD card then installing the OS is a very straight-forward process.


Information on types of SD cards 
 You will need to use a computer with an SD card reader. (If you don’t have one you can buy a USB SD Card reader)
 You will need to download the NOOBS installer (Offline & network install) at the NOOBS download page it is about 700mb. You can download the network install, but you will need an active network connection to your Pi for it to work correctly.
Once downloaded extract the files from the zip file.

 Format your SD card

You will need to format your SD card before you can copy the NOOBS files onto it.
Follow the steps below to do this:
1. You will need a formatting tool visit the SD Association’s website and download SD Formatter 4.0 for either Windows or Mac.
2. Follow the instructions to install the formatting software.
3. Insert your SD card into the computer or laptop’s SD card reader and check the drive letter allocated to it, e.g. G:/
4. In SD Formatter, select the drive letter for your SD card and format it.
5. Use Win32 Disk Imager to burn Raspbian









The Apache HTTP Server Project is an effort to develop and maintain an open-source HTTP server for modern operating systems including UNIX and Windows.

The Apache HTTP Server is a project of The Apache Software Foundation.


"The Apache Software Foundation is a cornerstone of the modern Open Source software ecosystem – supporting some of the most widely used and important software solutions powering today's Internet economy." – Mark Driver, Research Vice President, Gartner

more info about APACHE

Apache is the most used web server suggested is Raspberry Pi 3 with 1gb RAM but works with Raspberry Pi B 512 MB ram.
below are pictures of my setup


Next Pics are of my card reader and ssh console 



















Apache installation
Before installing the server, make sure we have an up-to-date machine. To do this we must have administrator rights, either because of the sudo command.
sudo apt update
sudo apt upgrade
sudo apt update
Once the Raspberry Pi is up to date, we will install the Apache server.
The password for sudo usage is one that you typed and generically it is raspberry
For some additional power, you can tweak  preferences-> Raspberry Configuration 
  1. You can increase processing power by overclocking it and enable ssh mode for better control using the network.
  2. You will be shown raspi-config on first booting into Raspbian. To open the configuration tool after this, simply run the following from the command line:

sudo raspi-config
sudo apt install apache2

By the way, we’ll take advantage of it to give rights to the apache file that you can easily manage your sites. To do this, run the following commands:
sudo chown -R pi:www-data /var/www/html/
sudo chmod -R 770 /var/www/html/

Check if Apache is working type the IP or if you have connected the display try using http://localhost or 127.0.0.1


One more method of check
f you do not already have a GUI on your Raspbian, or you use SSH to connect to your Raspberry, you can use the following command:
wget -O check_apache.html http://127.0.0.1
This command will save the HTML code of the page in the file “check_apache.html” in the current directory.
So you only have to read the file with the command
cat ./check_apache.html
If you see marked at a location in the code “It works! ” is that Apache is working.
Apache uses the directory “/var/www/html” as the roo

Now Time to install PHP
To install PHP, we will need first to get the PHP package, so, let’s download the PHP7 module for apache. To do this enter the following.
sudo apt-get install php7.0 libapache2-mod-php7.0 -y
Now we can place PHP files in the html folder, and they will be processed and displayed. For example let’s make a file called example.php
sudo nano /var/www/html/example.php
In this file add the following:
<?php
echo "Today's date is ".date('Y-m-d H:i:s');
?>
There we have it a fully working Apache2 + PHP Raspberry Pi Web Server working. but we cannot see PHP admin or visual interface as there is no database or DB management tool for it. Hence we install MySQL and PHPmyadmin.

Installing Raspberry Pi MySQL

First let’s install the MySQL server onto the Raspberry Pi.
sudo apt-get install mysql-server
You will be prompted to enter a password for the root user. Make sure you write this down as we will need to use this to access the MYSQL server and connect PHPMyAdmin to it.
mysql setup

Installing Raspberry Pi PHPMyAdmin

You will find that installing Raspberry Pi PHPMyAdmin is very easy.
I will go on the assumption you have already set up your web server and setup PHP for it. Please note that these steps will differ a bit if you are using Apache or NGINX.
Now let’s install the PHPMyAdmin package, you can do this by entering the following command on your Raspberry Pi.
sudo apt-get install phpmyadmin
It will now begin to install. You will be presented with a screen asking the type of web server you want it to run off. Select apache2 even if you are using NGINX since this doesn’t hugely matter for us.
Next, we will need to configure PHPMyAdmin to connect to our SQL database server. (The one we set up previously in installing the Raspberry Pi MYSQL step or the web server). To do this select yes at the next prompt.
PHPMyAdmin setup
The setup tool will now ask for a password, enter the one you set for root when setting up your SQL Server, this is needed for phpMyAdmin to talk with the SQL Server and manage your databases.
 Next, it will ask you to set a password for PHPMyAdmin itself. It is best to set this password to something different to your root SQL password. Make sure you remember it as this is the password you will need to access the interface.
With that done we can now proceed to configure our Apache for use with phpMyAdmin. 
To begin setting up Apache for use with phpMyAdmin enter the following command into the terminal:
sudo nano /etc/apache2/apache2.conf
Now at the bottom of this file enter the following line:
Include /etc/phpmyadmin/apache.conf
Once done save & exit by pressing CTRL +X and then y.
Now restart the Apache service by entering the following command:
sudo /etc/init.d/apache2 restart
To access phpmyadmin use

http://XXX.XXX.XXX.XXX/phpmyadmin
where http://XXX.XXX.XXX.XXX is your ip address of raspberry pi





Comments