The command line string to do the conversion uses TiMidity++ and LAME and on a Linux server are as straightforward as:

apt-get update; # as usual
apt-get install timidity lame; # install software

timidity file.mid -Ow -o - | lame - file.mp3
timidity file.mid -Ow -o - | lame - file.ogg

anywhere in inside the body tag you can go html5 style:

 <audio controls autoplay loop>
  <source src="music/StarWars.midi.ogg" type="audio/ogg">
  <source src="music/StarWars.midi.mp3" type="audio/mpeg">
  Your browser does not support the audio element.