So I have a Laravel PHP app on Nginx on Ubuntu 20.04. I have a simple deploy.sh script that will:
- Put Laravel into maintenance mode, so it returns a 503 error if anyone visits the site
- Pulls down the current source from github using a read-only deploy key
- Runs a composer install
- Disables maintenance mode
My goal is to have this shell script be executed by Nginx when it receives a validated HTTP Webhook request from github saying there was new code pushed to the repository.
Now for server security the Nginx user "www-data" has just read access to the files, and write access only where needed (ie /storage to write logs and save file uploads).
So I am going to need the shell script to run as the user who owns all the files "deploy". I am a bit confused when I look into this.
I read about setuid but that is is disabled on shell scripts for security in most Linux environments. Can someone confirm is this is true of Ubuntu 20.04 and if so is there another way to accomplish what I need?