The Manual Way
With reference to HHVM's own packaging material, you need to run hhvm as a daemon.
So, create a file at /etc/init.d/hhvm and paste this:
#! /bin/sh
test -x /usr/bin/hhvm || exit 0
case "$1" in
start)
/usr/bin/hhvm --config /etc/hhvm/server.hdf --user www-data --mode daemon
;;
stop)
start-stop-daemon --stop --quiet --oknodo --pidfile /var/run/hhvm/pid
;;
reload|force-reload|restart|try-restart)
$0 stop
$0 start
;;
status)
echo "No status"
;;
*)
echo "Usage: /etc/init.d/hhvm {start|stop|restart|status}"
exit 1
esac
exit 0
Now, we need to create the /etc/hhvm/server.hdf file. Here is a sample file: https://gist.github.com/sinaa/9151973
And for the /usr/share/hhvm/hdf/static.mime-types.hdf file, use this: https://github.com/hhvm/packaging/blob/master/hhvm/deb/skeleton/usr/share/hhvm/hdf/static.mime-types.hdf
And finally, create the directories:
- /var/run/hhvm
- /var/log/hhvm
And now simply start hhvm as a service: /etc/init.d/hhvm restart
The Automated Way: Installing pre-built packages (Ubuntu)
HHVM by default comes with all above, if you are using a pre-built version. You can install it as below (source):
# If this command is not found then do this: sudo apt-get install python-software-properties
sudo add-apt-repository ppa:mapnik/boost
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0x5a16e7281be7a449
echo deb http://dl.hhvm.com/ubuntu precise main | sudo tee /etc/apt/sources.list.d/hhvm.list
sudo apt-get update
sudo apt-get install hhvm
After reboot
To get your service to automatically run on boot, run this command:
sudo update-rc.d hhvm defaults