I am trying to initiate an AWS instance through a bash script. This bash script is invoked by a PHP script.
My example php script:
<?php exec("sh /var/www/html/pushDatToAWS.sh >> $trainLog"); ?>
My example bash script:
#!/bin/bash insId='i-abcde' aws ec2 start-instances wait --instance-ids $insId --region us-west-2
I have configured aws cli on my machine. I am getting the following error.
/var/www/html/pushDatToAWS.sh: 21: /var/www/html/pushDatToAWS.sh: aws: not found
The file has 777 rights and when I try to execute from terminal everything works perfectly. When I check with
which aws I get a response indicating
/home/name/.local/bin/aws. I have the path exported to bashrc.
I have tried hard coding the path to my aws start instance command:
/home/name/.local/bin/aws start-instances wait --instance-ids $insId --region us-west-2
For this I am getting permission denied error. I have tried changing the user ownership of the folder to
username:www-data. Neither worked.