Beaglebone Web Server


The Beaglebone Black Revision C is configured with Debian Wheezy and node.js is running a web server on port 80 and Apache web server on port 8080.

Since we need to use PHP, we will have to use the Apache web server. this leads to the following inconvenience:

A web browser will automatically go to port 80 when the port is not explicitly specified. So if we point a browser to


we will get the node.js web server which is not what we want.

There are two remedies:
  1. go to the port 8080
  2. removing or disabling node.js and changing the Apache port to 80

Solution 1

At this point, Apache is configured to listen on port 8080. Place an index.html file in var/www and point a web browser to



Solution 2

We will remove node.js and then configure a classic LAMP server.

apt-get remove npm
apt-get remove node*

remove /etc/systemd/system/multi-user.target.wants/bonescript

remove /var/lib/cloud9

edit
/etc/apache2/sites-enabled/000-default
change
<VirtualHost *:8080>
to
<VirtualHost *:80>

/etc/apache2/ports.conf
NameVirtualHost *:80
Listen 80

service apache2 restart

and now the web page will be at

http://192.168.7.2



Pre-Install

apt-get update


install ntp:

apt-get install ntp

Installing mySQL

apt-get install mysql-server

also, install phpmyadmin

apt-get install phpmyadmin

the user name of the administrative user will be root

Installing PHP

installing phpmyadmin will install PHP

(apt-get install php5)

(it will automatically install libapache2-mod-php5)


Testing the installation

go to







===================================================
-- old --
Problem:

On the PC connected through a USB to the Beaglebone, opening a web browser and going to http://192.168.7.2/test.php just downloads the file instead of running the PHP code.

Information:

test.php contains:
<html>
<head>
<title>Test</title>
</head>
<body>
<?php print('PHP is working on the BeagleBone!'); ?>
</body>
</html>

Observations:

When I open the same test.php which is located on the PC in a web browser, it works and the web browser displays
PHP is working on the BeagleBone!

On the PC connected through a USB, opening a web browser and going to http://192.168.7.2 redirects to /var/lib/cloud9/bone101/Support/bone101/

On Beaglebone:

Apache2 is already installed.
apt-get install apache2
apache2 is already the newest version.

installed mySQL
apt-get install mysql-server

installed PHP
apt-get install php5 libapache2-mod-php5

Running PHP on the command line works.

php test.php
<html>
<head>
<title>Test</title>
</head>
<body>
PHP is working on the BeagleBone!</body>
</html>

It just doesn't work with the web server.


a2enmod php5
Module php5 already enabled

apache2ctl -M
Loaded Modules:
 core_module (static)
 log_config_module (static)
 logio_module (static)
 version_module (static)
 mpm_prefork_module (static)
 http_module (static)
 so_module (static)
 alias_module (shared)
 auth_basic_module (shared)
 authn_file_module (shared)
 authz_default_module (shared)
 authz_groupfile_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 autoindex_module (shared)
 cgi_module (shared)
 deflate_module (shared)
 dir_module (shared)
 env_module (shared)
 mime_module (shared)
 negotiation_module (shared)
 php5_module (shared)
 reqtimeout_module (shared)
 setenvif_module (shared)
 status_module (shared)
Syntax OK



Conjecture:
node.js is the web server and Apache is overridden

Observations:
/usr/local/lib/node_modules/bonescript/server.js contains the line
listen(port, '/var/lib/cloud9');

this is consistent with the observation that the web root is at /var/lib/cloud9 and not at /var/www
which is the default for Apache

Apparently the bonescript is what starts the node.js web server.









1 comment:

  1. Great post.I'm glad to see people are still interested of Article.Thank you for an interesting read........Embedded Web Server

    ReplyDelete