[Unit] Description=Email Campaign Sender - background worker After=network.target [Service] Type=simple # Update this path to wherever you deployed the mailer/ folder: WorkingDirectory=/var/www/mailer # Update this to your CLI PHP binary (same one you'd get from `which php`): ExecStart=/usr/bin/php /var/www/mailer/worker.php # Restart automatically if it crashes, but not in a tight loop. Restart=on-failure RestartSec=10 # Run as the same user that owns the mailer files / data folder # (so it can write to data/ and logs/ without permission issues). # Replace with your actual deploy user, e.g. www-data, ec2-user, ubuntu. User=www-data Group=www-data # Basic hardening (safe defaults; loosen if your setup needs it) NoNewPrivileges=true [Install] WantedBy=multi-user.target