Error trying to send sms by php

∥☆過路亽.° 提交于 2019-12-25 03:29:30

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!