Overview :
- Download the latest Rasbian
- Prepare a SD / Micro SD card to receive the downloaded Images.
- Un compress and Transfer the downloaded Raspbian Image to the SD / Micro SD card.
- Install Raspbian.
- Configure Raspbian for a static network.
- Install Apache Web Server
- Install PHP and Associated Packages
- Install MySql
- Configure your router to access your Webserver and a domain name that points to your webserver.What you will need :
- Raspberry Pi 2 Model B or one of its clones like Banana Pi M1 or M2 or Banana Pro
- Ethernet connection or a supported USB Wifi adapter for the Pi
- SD or Micro SD Card that fits into your Pi (4GB or above is recommended)
- USB Keyboard and Mouse
- Connection to a TV or Monitor
You should seriously consider :- Learning about SSH and how to remotely access the Pi from another machine on your network.
- Learning about Port forwarding settings for your Router.
STEP 1 : Install Raspbian ( Xem bai 2 trong Blog nhe)
STEP 2 : Give the Pi a static IP address
By default, the Pi is set to ask for a dynamic IP address from the router. You will need to change this setting to a fixed IP addresssince you will be hosting a webpage on the Pi and need the address to be fixed.
Assigning a Static IP address to the Pi can either be done at the Router level (which is fairly easy but the steps to do this are router’s model and brand specific) or at the Raspberry Pi level (outlined below).
Note : replace the x in the lines below with what appears on your screen as you type in the commands.
Log on Raspbian and enter the following commands at the terminal :
- “ifconfig” (ifconfig displays details of your current network connection )
- Write down the values next to inet add:192.168.x.xxx. These numbers is the IP address that your Pi is currently at.
- Also write down the Broadcast Range (Bcast) and Subnet Mask (Mask) that appear next to the inet add.
- To get information from your router, type in “sudo route -n“. This will give you the gateway and destination values.
- Write down the Gateway = 192.168.x.x & Destination = 192.168.x.x
We have now obtained all of the data that we need to setup our Raspberry Pi with a static IP address, it’s time to save it to a config file.
Type in “sudo nano /etc/network/interfaces” ( nano is a text editor and will open the file interfaces located in the folder /etc/network)
In nano, look for the the line that reads “iface eth0 inet dhcp”. This line is telling the ethernet “eth0” networking interface to use “dhcp” (dynamic IP). Firstly, replace “dhcp or manual” with “static”.
Next , add the following lines directly below the line you just altered, with the data you had written down earlier.
address your.chosen.IP.address
netmask your.netmask
network your.destination
broadcast your.broadcast.range
gateway your.gateway
The file should look something similar to the image below :
Save your file and exit out of nano by pressing ctrl+x
Reboot your Pi by typing in “sudo reboot“
Once rebooted, your Pi will be on a static IP address. Crosscheck this by typing in “ifconfig” again.
STEP 3 : Install Apache, PHP, MySQL and associated Libraries
For your Raspberry Pi to serve up websites, you will need to install a webserver. Apache is a program that listens for server access requests from Internet browsers and grants them, if permitted. So if you want anyone to be able to access a website on your Raspberry Pi—including yourself—you need to install a Web server.
To install Apache, type in “sudo apt-get install apache2″
To install MySQL, type in “sudo apt-get install mysql-server″ (lệnh này sẽ cài bản 5.5)
Type in the IP address of the Pi onto the browser of another computer on your network and you should see “It works!” The default landing page of Apache.
To allow your Apache server to process PHP files, you’ll need to install PHP5 and the PHP5 module for Apache.
At the Terminal, Enter “sudo apt-get install php5 libapache2-mod-php5 -y“
Once all the software is installed, restart Apache by typing in “sudo service apache2 restart“
The website is hosted at “/var/www/index.html” on your Pi.
You can edit the file or replace it with your own website.
STEP 4 : Pointing your Domain Name ; Handling Dynamic IP and giving access to the Pi from the world wide web.
Almost all ISPs provide a dynamic dns address to your home internet connection. This is done for a variety of reasons – one of which is to prevent hackers from attacking a single address consistently.
No comments:
Post a Comment