英文:
No such file or directory when run as service?
问题
当我从终端运行我的应用程序 sudo -u www-data ./scarga
并打开浏览器时,模板文件能够正常提供服务,一切都正常。命令是在 /var/www/html/scarga.local/
目录下执行的。
当我以 sudo service scarga start
的方式运行我的应用程序时,它显示:open ./resources/views/index.html: no such file or directory
。
具有HTTP处理程序的文件:https://pastebin.com/MU7YDAWV
scarga.service 文件:https://pastebin.com/eBL3jJFx
项目的目录树:https://pastebin.com/rFVa8A3P
index.html
文件的权限为:
-rwxr-xr-x 1 www-data www-data 3586 Jun 28 14:27 index.html
为什么会出现这种情况,如何解决?
谢谢!
英文:
When i run my application from terminal sudo -u www-data ./scarga
and open browser, the template file served well, everything ok. Command executed from /var/www/html/scarga.local/
directory.
When i run my application as sudo service scarga start
it says: open ./resources/views/index.html: no such file or directory
File with HTTP handler: https://pastebin.com/MU7YDAWV
The scarga.service file: https://pastebin.com/eBL3jJFx
Tree of project: https://pastebin.com/rFVa8A3P
Rights for index.html file
-rwxr-xr-x 1 www-data www-data 3586 Jun 28 14:27 index.html`
Why this happens and how to solve?
Thank you!
答案1
得分: 2
你需要在脚本中使用WorkingDirectory=
来设置正确的工作目录,可能是这样的:
WorkingDirectory=/var/www/html/scarga.local
英文:
You need to set the correct working directory in your script using WorkingDirectory=
- presumably:
WorkingDirectory=/var/www/html/scarga.local
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论