Search This Blog

Saturday, April 8, 2017

Raspberry Pi Web server & static IP trick!

To set a Raspberry Pi web server we need to install the popular web server (Apache).
Apache can serve HTML pages over HTTP but needs additional modules to handle dynamic pages using PHP.

To install Apache on the Pi run the following command in the command line:

sudo apt-get install apache2 apache2-doc apache2-utils
For the additional modules run:
sudo apt-get install libapache2-mod-php5 php-pear php5-xcache
For mysql server /PHP support:
sudo apt-get install php5-mysql mysql-server mysql-client
To test the web server enter in web browser

To give our Pi a static IP address we need to modify /etc/network/interfaces
sudo nano /etc/network/interfaces
and add the static IP information as follows:

iface eth0 inet static
address 192.168.0.x

Now we need to force the dhcpcd daemon to get the IP address we just specified, for that we need to modify/etc/dhcpcd.conf by running the command: 
sudo nano /etc/dhcpcd.conf 

at end of file add the following 
#Static IP address 
interface eth0 
static ip_address = 192.168.0.x 
static routers = 
static domain_name_server =

No comments:

Post a Comment