Sunday, July 31, 2016

centos , linux , apache permission issue



I have a php file which executes a shell script





$ip_access = $_GET['ip_access'];
// run knock app
exec("/home/knock.sh ".$ip_access);



however when I access it I receive the following error in the logs "sh: /home/knock.sh: Permission denied"
I created a new user and added it in the apache httpd.conf file but is still not working . Any advice how to set the permissions or how can I grant more access to the user to make it work would be highly appreciated .


Answer



If you are running the script as the appropriate user, you may need to add the execute permission +x to the file. You can do it using:




chmod +x /home/knock.sh


As an alternative, you can use the following command (no need to add execute permission):



exec("bash /home/knock.sh ".$ip_access);

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...