问题
I installed gammu in linux and I can send sms using the shell command. But when I add the command in a php page I get the following error:
$phone = 3588459717;
echo shell_exec ('gammu sendSms TEXT '.$phone.' -text "test msg"');
Error opening device, it does not exist.
回答1:
Most likely the web server is running as different user and Gammu running under this user does not see your configuration file and/or does not have permissions to open the device.
回答2:
php process under apache Server, runs as a user with permission www-data:www-data try to ad permission, please start console as root user and add permission dialout to user www-data.
id www-data
uid=33(www-data) gid=33(www-data) groups=33(www-data)
usermod -a -G dialout www-data
id www-data
uid=33(www-data) gid=33(www-data) groups=33(www-data), 188(dialout)
sudo service apache2 restart
after apache restart, run your php script
来源:https://stackoverflow.com/questions/30309309/error-trying-to-send-sms-by-php