Using the HP MediaVault as a Web Server

By Peter Michael Bruun


See also: My Family Home

Overview of my MediaVault pages:

Why use the MV as a Web Server?

The second generation HP Media Vault can be used as a webserver with some nice advantages: I am using the mv5020 Pro, which is the European version of the box known as mv2120 in the US. The procedures described here probably also apply to the other generation 2 MediaVault versions - mv5140 and mv5150. Below, I am just assuming mv5020 for simplicity.

Of course, the MediaVault is a very small box, and it definitely has some limitations:

The page you are presently viewing is served by my MediaVault. I have done little to make it "look nice".

For some more interesting pages, take a look at the web-pages I set up for my wife, who is a practicing Acupuncturist. Her site is in the Danish language - as she does not often travel abroad to do treatments, we have't translated to English. Anyway, if you happen to be in the greater Copenhagen area, and you have some ailment - please consider her treatments, which I can say have worked extremely well for me, and I am actually terrified of needles. (End of commercial.)

Note that the information given here, simply reports my experience with the mv5020. I have no experience with other models of HP MediaVault than the mv5020.

I provide no warranty, and you should proceed at your own risk. A risk, which is true and real - as stated below.

Before you start: BE WARNED

This page describes my personal experience with the HP MediaVault, and implies no liability and no endorsement or support by HP, whatsoever.

Following these instructions is likely to void any warranty on the HP MediaVault.

Following these instructions are highly likely make your HP MediaVault completely and utterly unresponsive and cause loss of data. This is known as "bricking" the MediaVault.

Before proceeding, you should read the prerequisites for Hacking the HP MediaVault here.

Preparations for setting up a Web Server

Before you begin, consider these items:

Changing the root page

Your MediaVault runs an Apache webserver. It has been configured by HP so the default page in each directory is named "main.htm". This is the page showing the "Welcome to the MediaVault" and has no login.

If you go to my website root, you will see, that it contains an altered main.htm page which has links to the original page, which I re-named to admin.htm. If you still want access to the "Welcome" page, you would want to do something similar. Feel free to use my main.htm as a starting point, if you have nothing better.

So assuming you have placed your new main.htm in your Documents/web directory (as seen from Windows), this is what you want to do (slowly, one step at a time, verifying that everything went well):

  cd /usr/htdocs
  cp main.htm admin.htm
  cp /share/1000/Documents/web/main.htm .
  chmod 444 main.htm

Putting Web-pages on the disk

Now, if you are happy to have all your web-pages reside in the flash-memory (firmware) section of the MediaVault file-system, you are already done. You can in principle put as many pages as you want in the htdocs directory, and you have the advantage, that the disk does not have to spin-up, when pages here are accessed after an idle perod. However, you walk a tight-rope every time you work in the firmware - every time you change something here, you risk "bricking" the MediaVault.

So we want to instruct Apache to serve files from some directory or directories on the hard-drives, for example you could create Documents/web/htdocs/mypages from the windows side, and then maintain that part of the web-site entirely from Windows, without thinking about the MediaVault.

To do this, you need to edit the file /etc/inc/ using vi or following the procedure described above.

Locate the line saying: UserDir public_htm, and insert the following lines above it:

Alias /mypages /share/1000/Documents/web/htdocs/mypages
<Files "/share/1000/Documents/web/htdocs/mypages">
    AllowOverride None
    Order allow,deny
    Allow from all
When the file has been edited, you should re-boot the HP MediaVault and pray that it has not turned into a brick. Now you can begin to put your .htm or .php pages in the mypages directory. You do not have to worry about Linux/Windows line-endings here, since HTML does not care.

Enabling php processing of htm pages

Pages ending in .php will automatically be processed by the PHP pre-processor, which will allow you to have dynamic contents on your web-pages. Personally, I am not fond of exposing externally, whether some page was static or dynamic, so I have chosen to have PHP pre-processing even on .htm pages.

This is done by changing the line saying:

AddType text/html	.htm
to the following:
AddType application/x-httpd-php .htm
The disadvantage of this change is a slight overhead when serving the .htm pages.

Connecting to the Database from PHP

The postgreSQL database cann be accesssed from the ssh shell using the command:
psql postgres postgres
You can access the database from PHP-pages as described here.

If you are going to add your own tables to the database, I suggest you create a separate database user, mydb, for that purpose. See Using the HP MediaVault as a Database Server for more information.

The postgreSQL database stores its data on the real disk-drives, so you have the full disk capacity of your MediaVault at your disposal.

Valid HTML 4.01 Transitional