php - LAMP Web Server: Executing Application on Server Side can't detect USB device -
i have set lamp web server , looking run application on server side when client clicks button on servers web interface. application usb device, serial number, open , send packet of bytes device.
i have index.html, has button action call test.php file uses shell_exec() call application.
when application invoked through web interface, application writes out error indicating couldn't open usb device (this built in error application, application works, can not locate usb device).
but when invoke application via terminal, application finds usb device , writes no problem.
i looking advice! i'm doing feasible? if so, how can application find usb device when invoked via web interface? have feeling has permissions, never know.
test.php:
<?php echo shell_exec("/home/pi/fdti_test/fdti_test_application"); ?>
note: usb device connected, works great driver, , connected server via usb.
the application works when invoked via terminal on server side, not when invoked via web interface.
i think on right track being permissions issue.
in typical lamp stack, php process runs module in apache process, unless you've configured differently. in server os of choice, php process runs user 'www-data' default.
probably easiest solution give sudo permission web user account, , set sudoers file nopasswd. insecure, in rare cases.
<?php echo shell_exec("sudo /home/pi/fdti_test/fdti_test_application"); ?>
the next easiest option give web user account permission write usb device directly. depending on distribution, may need add user 'adm' group.
sudo usermod -a -g adm www-data
again, may not secure method, more secure first option.
lastly, hardest solution install patched version of apache allows suexec. equally insecure second option, more difficult implement. (i have included link tutorial, i'm limited 2 links first answer.)
hope helps!
Comments
Post a Comment