Beehive Instrumentation Project-3: Apache Server, Python in PHP

While running the Raspberry Pi 2-B off the drill battery, I installed the Apache-2 server and MySQL.

See for details.

I want to run the temperature and humidity logging, IR and USB cameras, and other possible instruments like weight measurement from a local web server on the remote RPi.  The first step is to run a PHP script on the server, which in turn selects the “driver” code for the attached devices.  The learning PHP script runs a simple Python script.

See for the basic ideas.

I wrote the PHP script “index.php”, which is placed in the RPi directory /var/www, where the Apache server runs it as the default start up code instead of index.html.

echo “hello world.”;
echo “<br>”;
$command = escapeshellcmd(‘python’);
$output = shell_exec($command);
echo $output;
echo “<br> I’m here in php”;

The Python script “”:

#!/usr/bin/env python
print “I’m here in Python”

When the IP address of the RPi is entered into the Firefox browser, this is the result:

RPi2B server Firefox browser image

RPi2B server Firefox browser image


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s