unable to run command as sudo in php (CentOS 7)
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I need to run a sudo command from a PHP script in CentOS 7, but I am getting an error:
sudo: no tty present and no askpass program specified
I have edited my sudoers file with the following lines, as others have advised:
don't require tty:
Defaults:apache !requiretty
Set no password for apache user:
apacheÃÂ ALL=(root) NOPASSWD: /path/to/app, /path/to/app2
(I have double-checked that these paths are correct). My errors persist. Any thoughts?
centos sudo php
add a comment |Â
up vote
0
down vote
favorite
I need to run a sudo command from a PHP script in CentOS 7, but I am getting an error:
sudo: no tty present and no askpass program specified
I have edited my sudoers file with the following lines, as others have advised:
don't require tty:
Defaults:apache !requiretty
Set no password for apache user:
apacheÃÂ ALL=(root) NOPASSWD: /path/to/app, /path/to/app2
(I have double-checked that these paths are correct). My errors persist. Any thoughts?
centos sudo php
1
Is that the only sudoers line for apache? Could it be hitting another rule?
â Jeff Schaller
Sep 25 at 20:17
It is the only line, yes
â Michael Riordan
Sep 26 at 8:46
You would better find another way of doing that. Apache has another user for security reasons, givingsudo
to Apache is a very bad idea.
â Rui F Ribeiro
Sep 26 at 11:39
apache = NOPASSWD: /path/2/app, /path/2/app2
could you try this?
â Diogo Jesus
Sep 26 at 12:17
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I need to run a sudo command from a PHP script in CentOS 7, but I am getting an error:
sudo: no tty present and no askpass program specified
I have edited my sudoers file with the following lines, as others have advised:
don't require tty:
Defaults:apache !requiretty
Set no password for apache user:
apacheÃÂ ALL=(root) NOPASSWD: /path/to/app, /path/to/app2
(I have double-checked that these paths are correct). My errors persist. Any thoughts?
centos sudo php
I need to run a sudo command from a PHP script in CentOS 7, but I am getting an error:
sudo: no tty present and no askpass program specified
I have edited my sudoers file with the following lines, as others have advised:
don't require tty:
Defaults:apache !requiretty
Set no password for apache user:
apacheÃÂ ALL=(root) NOPASSWD: /path/to/app, /path/to/app2
(I have double-checked that these paths are correct). My errors persist. Any thoughts?
centos sudo php
centos sudo php
edited Sep 26 at 8:38
asked Sep 25 at 19:29
Michael Riordan
386
386
1
Is that the only sudoers line for apache? Could it be hitting another rule?
â Jeff Schaller
Sep 25 at 20:17
It is the only line, yes
â Michael Riordan
Sep 26 at 8:46
You would better find another way of doing that. Apache has another user for security reasons, givingsudo
to Apache is a very bad idea.
â Rui F Ribeiro
Sep 26 at 11:39
apache = NOPASSWD: /path/2/app, /path/2/app2
could you try this?
â Diogo Jesus
Sep 26 at 12:17
add a comment |Â
1
Is that the only sudoers line for apache? Could it be hitting another rule?
â Jeff Schaller
Sep 25 at 20:17
It is the only line, yes
â Michael Riordan
Sep 26 at 8:46
You would better find another way of doing that. Apache has another user for security reasons, givingsudo
to Apache is a very bad idea.
â Rui F Ribeiro
Sep 26 at 11:39
apache = NOPASSWD: /path/2/app, /path/2/app2
could you try this?
â Diogo Jesus
Sep 26 at 12:17
1
1
Is that the only sudoers line for apache? Could it be hitting another rule?
â Jeff Schaller
Sep 25 at 20:17
Is that the only sudoers line for apache? Could it be hitting another rule?
â Jeff Schaller
Sep 25 at 20:17
It is the only line, yes
â Michael Riordan
Sep 26 at 8:46
It is the only line, yes
â Michael Riordan
Sep 26 at 8:46
You would better find another way of doing that. Apache has another user for security reasons, giving
sudo
to Apache is a very bad idea.â Rui F Ribeiro
Sep 26 at 11:39
You would better find another way of doing that. Apache has another user for security reasons, giving
sudo
to Apache is a very bad idea.â Rui F Ribeiro
Sep 26 at 11:39
apache = NOPASSWD: /path/2/app, /path/2/app2
could you try this?â Diogo Jesus
Sep 26 at 12:17
apache = NOPASSWD: /path/2/app, /path/2/app2
could you try this?â Diogo Jesus
Sep 26 at 12:17
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
This line does not give sudo
permissions to app and app2:
apache ALL=(root) NOPASSWD: /path/to/app /path/to/app2
What the above line does is give sudo permissions to run /path/to/app
, only if you also pass a single argument to it of /path/to/app2
. To specify multiple commands, they need to be separated by a comma:
apache ALL=(root) NOPASSWD: /path/to/app, /path/to/app2
ah, that was just a typo in my post, which I've now changed
â Michael Riordan
Sep 26 at 8:40
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
This line does not give sudo
permissions to app and app2:
apache ALL=(root) NOPASSWD: /path/to/app /path/to/app2
What the above line does is give sudo permissions to run /path/to/app
, only if you also pass a single argument to it of /path/to/app2
. To specify multiple commands, they need to be separated by a comma:
apache ALL=(root) NOPASSWD: /path/to/app, /path/to/app2
ah, that was just a typo in my post, which I've now changed
â Michael Riordan
Sep 26 at 8:40
add a comment |Â
up vote
1
down vote
This line does not give sudo
permissions to app and app2:
apache ALL=(root) NOPASSWD: /path/to/app /path/to/app2
What the above line does is give sudo permissions to run /path/to/app
, only if you also pass a single argument to it of /path/to/app2
. To specify multiple commands, they need to be separated by a comma:
apache ALL=(root) NOPASSWD: /path/to/app, /path/to/app2
ah, that was just a typo in my post, which I've now changed
â Michael Riordan
Sep 26 at 8:40
add a comment |Â
up vote
1
down vote
up vote
1
down vote
This line does not give sudo
permissions to app and app2:
apache ALL=(root) NOPASSWD: /path/to/app /path/to/app2
What the above line does is give sudo permissions to run /path/to/app
, only if you also pass a single argument to it of /path/to/app2
. To specify multiple commands, they need to be separated by a comma:
apache ALL=(root) NOPASSWD: /path/to/app, /path/to/app2
This line does not give sudo
permissions to app and app2:
apache ALL=(root) NOPASSWD: /path/to/app /path/to/app2
What the above line does is give sudo permissions to run /path/to/app
, only if you also pass a single argument to it of /path/to/app2
. To specify multiple commands, they need to be separated by a comma:
apache ALL=(root) NOPASSWD: /path/to/app, /path/to/app2
answered Sep 25 at 22:11
jordanm
29.3k27891
29.3k27891
ah, that was just a typo in my post, which I've now changed
â Michael Riordan
Sep 26 at 8:40
add a comment |Â
ah, that was just a typo in my post, which I've now changed
â Michael Riordan
Sep 26 at 8:40
ah, that was just a typo in my post, which I've now changed
â Michael Riordan
Sep 26 at 8:40
ah, that was just a typo in my post, which I've now changed
â Michael Riordan
Sep 26 at 8:40
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f471410%2funable-to-run-command-as-sudo-in-php-centos-7%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
Is that the only sudoers line for apache? Could it be hitting another rule?
â Jeff Schaller
Sep 25 at 20:17
It is the only line, yes
â Michael Riordan
Sep 26 at 8:46
You would better find another way of doing that. Apache has another user for security reasons, giving
sudo
to Apache is a very bad idea.â Rui F Ribeiro
Sep 26 at 11:39
apache = NOPASSWD: /path/2/app, /path/2/app2
could you try this?â Diogo Jesus
Sep 26 at 12:17