link7722 Posted January 26, 2011 Share Posted January 26, 2011 Hi, I am trying to use php to pass some commands to my linux box.From my webpage I am using the shell_exec function which is working OK but for some administrative tasks in linux I must have root access. As I am sending the commands from the webpage the apache user is used and so I am not allowed to do several tasks. I have also tried to use a bash script to pass the commands but with no result. Any ideas ? Quote Link to comment Share on other sites More sharing options...
Cagecrawler Posted January 26, 2011 Share Posted January 26, 2011 You can use the sudo command to get superuser access. There's multiple ways to get sudo to run silently if that's what you need. Quote Link to comment Share on other sites More sharing options...
link7722 Posted January 26, 2011 Author Share Posted January 26, 2011 I already tried sudo but I get the following error in apache error.log: sudo can only be run in tty Thanks Quote Link to comment Share on other sites More sharing options...
Cagecrawler Posted January 26, 2011 Share Posted January 26, 2011 You can run the visudo command and comment out the line that says Defaults requiretty Quote Link to comment Share on other sites More sharing options...
link7722 Posted January 26, 2011 Author Share Posted January 26, 2011 Now the error log responds with no tty present and no askpass program . I am using the latest Centos version. Quote Link to comment Share on other sites More sharing options...
link7722 Posted January 26, 2011 Author Share Posted January 26, 2011 OK solved. I needed to change the sudoers file for the apache user Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.