Last active
June 23, 2021 05:06
-
-
Save ebta/4537eebdd4731c81e30a84fe233ab46b to your computer and use it in GitHub Desktop.
Run php application (cli) as service (daemons) in Ubuntu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Save this file ex. /etc/systemd/system/myapp.service | |
# then run using: systemctl <start|status|restart|stop|enable> myapp | |
[Unit] | |
Description=My PHP APP Service | |
# May your script needs MySQL or other services to run, eg. MySQL Memcached | |
Requires=mysqld.service memcached.service | |
After=mysqld.service memcached.service | |
[Service] | |
User=user | |
Type=simple | |
TimeoutSec=0 | |
PIDFile=/var/run/myapp.pid | |
ExecStart=/bin/sh -c '/usr/bin/php -f /var/www/app/myapp.php 2>&1 > /var/log/myapp.log' | |
KillMode=mixed | |
Restart=on-failure | |
RestartSec=42s | |
[Install] | |
WantedBy=default.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment