This helps to setup MEGAM_HOME in your .bashrc directory. Note I have set it up under /var/lib/megam which mean you need root access when you run megam_gateway the first time.
We recommend you set it up under your /home/<user>/<xyz> when you do it in development.