Hi,
I call a shell script through php.The shell script need root privelages,for this I edit the sudoers file and give the root permission to apache.
Every thing in the shell script working fine except the httpd restart.But when i run it from command lne its working fine.Here is my flow
my client.php in /var/www/html
passthru(" sudo /usr/bin/php -f /home/server.php"")
/home/server.php
exec("cd /home/gaea/shell/;sh LoginMysql.sh", $output ,$returnValue);
my shell script
..
/opt/tomcat/bin/startup.sh
/etc/init.d/httpd restart
apache log
caught SIGTERM, shutting down
please help me out this problem,sorry for my poor english
Thanks
Govindan
call shell script from php exec()
Moderator: General Moderators
Re: call shell script from php exec()
1. I hope you gave root permission to apache only for executing this command with these parameters.
2. Could you explain what are you trying to achieve in general? Why you need the httpd service restarted, what does "sh LoginMysql.sh" do? Etc.
2. Could you explain what are you trying to achieve in general? Why you need the httpd service restarted, what does "sh LoginMysql.sh" do? Etc.
There are 10 types of people in this world, those who understand binary and those who don't
Re: call shell script from php exec()
The shell script will create a new instance of tomcat,create a database in mysql and set the virtual host in httpd.conf file (listen the newly created tomcat ports).so I start the tomat and restart apache for configuration take effect.
when i run php -f /var/www/html/client.php .the shell script run successfully.The problem is run from browser only.i put exec("whoami") it display root.
Thanks
Govindan
when i run php -f /var/www/html/client.php .the shell script run successfully.The problem is run from browser only.i put exec("whoami") it display root.
Thanks
Govindan
Re: call shell script from php exec()
I've never worked with tomcat, but maybe I'll be still in help:
http://httpd.apache.org/docs/2.0/vhosts/mass.html
Have you looked at it?
http://httpd.apache.org/docs/2.0/vhosts/mass.html
Have you looked at it?
There are 10 types of people in this world, those who understand binary and those who don't