Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On my ubuntu server I have an application MyApp which runs as a daemon with its own user myapp.

Then I have a web application MyPortal which runs in apace httpd as user www-data. This application serves a web page with a Redeploy MyApp button. When clicking this button I want to start the script redeploymyapp. This script stops the MyApp deamon, upgrades the application and starts the daemon again.

The problem is, that the redeploymyapp script needs to be executed by the user myapp, while MyPortal is running as www-data.

What is te best way to solve this problem?

share|improve this question
up vote 0 down vote accepted

Configure sudo to let www-data execute that script as either myapp or root (depending on which is preferred), then execute it as sudo redeploymyapp.

It should be as simple as:

www-data ALL=(myapp) NOPASSWD: redeploymyapp

added via visudo. Probably also worth noting that redeploymyapp should be completely self-contained (that is, no arguments provided by a web request, no use of environment variables, etc.)

share|improve this answer
Perhaps the following instead? www-data ALL=(myapp) NOPASSWD: /path/to/redeploymyapp – andol Mar 29 '10 at 12:02
Fixed, thanks.... – James Cape Mar 29 '10 at 22:59

One option is to let MyPortal, when the button is pressed, write a value to a in a database or to a file. In turn MyApp continuously monitors that database/file.

Otherwise you can use some suexec magic to make sure that redeploymyapp can be run as the myapp user. What suexec solution is the most suitable really depends on what scripting language you are using etc.

(Dealing with PHP scripts I have good experiences with suPHP.)

Then there is also, as James mentions, the sudo route.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.