Using the HP MediaVault as a Web Server
By Peter Michael Bruun
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.
- Support for plain HTML as well as PHP and JSP.
- Database support for your pages - PostgreSQL is already running.
- Lots of diskspace for your web-application.
- Low-cost, while free from that unwanted advertising, which budget webhotels typically insist on placing on your pages.
Of course, the MediaVault is a very small box, and it definitely has some limitations:
- Not a lot of CPU power - it is only suitable for low traffic sites.
- Response times can be poor - particularly if it is working for you or if the disks have stopped - you can customize the idle time in the normal administration interface
- Your pages may be unavailable from time to time. For example, the MediaVault must be manually re-started if there is a power-failure.
- No firewall - make sure that you get some firewall capability from your router or your network provider, so only port 80 is accessible from the internet
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:
- You should have a fixed IP address that can be accessed from the Internet. This may be included by your internet provider, or it may cost extra. If you are not paying for a fixed address, you could either rely on the TZO subscription coming with the MV (I have not tried that, so I have no opinion), or you may hope that your provider will not actually change your assigned dynamic IP address lease, even though they have the right to do so. In that case your IP address seems to be ''. (Yes, this page is dynamic).
- Get a domain name, i.e. a web-address assigned to your IP address. Again, this may be a service that your provider offers as part of your subscription. You can also get domain from one of the countless providers of web-hotel services - but if that was what you wanted, you would not be setting up your MediaVault. I chose a "free" DNS service instead. This means that the DNS service itself is free, but you still need to pay the registrar for the top-level domain (regional, .com, .net, ...)
- Make sure that you can now access your "Welcome to the MediaVault" page from the internet. If you are presently on the same router as your MediaVault, then you can test it by clicking here.
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):
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/func_httpd.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
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.