torvin
torvin

Reputation: 7091

How to execute a privileged action from a CGI script

I want to restart a linux service from a shell CGI script, which obviously requires root rights. I'm kind of out of options that I know of:

What are the best practices of doing something like that?

Upvotes: 0

Views: 333

Answers (1)

Dextro67
Dextro67

Reputation: 205

Another option is to use a sudoer . As a best practice always provide the apache user as little rights as it needs.

Edit the sudoers file with sudo visudo and add a line

apache        ALL = NOPASSWD: /usr/sbin/service /usr/local/myapp * 

Upvotes: 1

Related Questions