Web目录结构问题
这是我的目录结构:
-st.救护车
---public_html
---资源
我的文档根目录是 public_html
。我在 resources
中有一个脚本,需要安全地执行(这意味着:普通用户不应该能够执行它)。我该怎么做?
This is my directory structure:
-st.ambulance
---public_html
---resources
My document root is public_html
. I have a script in resources
that I need to execute securely (meaning: normal users shouldn't be able to execute it). How would I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果普通用户无法在浏览器中访问它,他们将无法执行它。如果它不在您的文档根目录中,他们应该无法访问它。因此,它已经是安全的,除非文档根目录中的脚本之一包含它,或者您的网站被黑客攻击。
至于您自己执行脚本,请了解它是否应该从命令行运行还是作为网页运行。如果它可以在命令行运行,只需 ssh 并运行它。如果它需要作为网页运行,请让您的 Web 服务器将资源目录提供给管理(子)域,并通过 https 进行保护,并使用基本 http 身份验证等密码保护它。
Normal users already won't be able to execute it if they can't get to it in their browser. If it's not in your document root, they shouldn't be able to get to it. So, it's already safe, unless one of the scripts in your document root is including it, or your site gets hacked.
As far as executing the script yourself, find out whether it should be run from the command line or as a web page. If it can run at the command line, just ssh in and run it. If it needs to be run as a web page, have your web server serve the resources directory to an admin (sub)domain, secured by https, and password protect it with something like basic http authentication.
剧本是什么?我想这并不重要,但是你可以做的是使用:
我应该补充一点,你当然需要适当地设置你的路径。
What is the script? I guess that doesn't matter so much anyway, but what you can do is use:
I should add that you of course need to set up your path appropriately.