php-7ubuntu-16.04kirby

How do I set php to start on reboot?


I am using Kirby on Ubuntu 16.04, and every time I reboot I have to login on my server, go to my website folder and type

sudo php -S 0.0.0.0:80

for the server to start.

What's a correct way of getting this to start automatically after a reboot?

Sorry for the trivial question, I just don't seem to be able to find a simple answer on the web...


Solution

  • You can use root's crontab with @reboot directive. Edit it with sudo crontab -e

    @reboot cd /path/to/directory && php -S 0.0.0.0:80
    

    Notice that there is no sudo before the php command, because it's run from root's crontab.