如何正确配置 Symfony 服务器(在共享主机上)?

发布于 2024-09-02 18:39:07 字数 347 浏览 7 评论 0原文

我已经决定学习 Symfony,现在我正在阅读《Practical Symfony》这本书的开头部分。阅读“Web 服务器配置”部分后我有一个问题。

该手册描述了如何正确配置服务器:浏览器只能访问 web/ 和 sf/.../ 目录。该手册对此有很好的说明,作为一名 Linux 用户,我可以毫无问题地遵循这些说明并使一切在我的本地计算机上正常运行。然而,这涉及编辑 VirtualHost 条目,这在常见的共享托管服务器上通常并不容易做到。所以我想知道 Symfony 开发人员使用什么常用技术在共享托管环境中获得相同的结果?我想我可以通过在根目录中添加“拒绝所有”,然后在允许的目录中覆盖该规则来做到这一点。但是我不确定这是否是最简单的方法以及通常使用的方法。

I've decided to learn Symfony and right now I am reading through the very start of the "Practical Symfony" book. After reading the "Web Server Configuration" part I have a question.

The manual is describing how to correctly configure the server: browser should have access only to web/ and sf/.../ directories. The manual has great instructions regarding this and being a Linux user I had no problem following them and making everything work on my local machine. However that involves editing VirtualHost entries which normally is not easy to do on common shared hosting servers. So I wonder what is the common technique that Symfony developers use to get the same results in shared hosting environment? I think I can do that by adding "deny from all" in the root and then overwriting that rule in the allowed directories. However I am not sure if that's the easiest way and the way that is normally used.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

等待我真够勒 2024-09-09 18:39:07

如果您可以在 public_html 目录之外添加文件,请将所有目录放在那里,并将您的 Web 目录中的所有文件放在 public_html 目录中(如果您的应用程序需要,则放置您的 sf 目录),在这种情况下,只有 Web 文件可以访问在公共上,但是如果您只能访问 public_html 目录并且无法在其外部添加目录,您可以将所有文件放入 public_html 内的文件夹中并保护它(我认为 .htaccess 可以做到这一点),网络文件应该也位于 public_html 中,但您必须更改 index.php 的 require_once(dirname(__FILE__).'/../config/ProjectConfiguration.class.php'); 以指向新位置项目配置文件的。

但由于这是一个共享托管环境,其他人仍然有可能访问您的文件,但这主要取决于托管提供商如何设置其服务器。

If you can add files outside public_html directory, put all the directories there and put on the public_html directory all the files inside your web directory (put your sf directory if it was needed by your app), In this case only the web files are accessible on the public, however if you can only access the public_html directory and cannot add directory outside it, you can put all your files to a folder inside the public_html and secure it (I think .htaccess can do the trick), the web files should be in the public_html also but you must change the require_once(dirname(__FILE__).'/../config/ProjectConfiguration.class.php'); of your index.php to point to the new location of the ProjectConfiguration file.

But since this is a shared hosting environment, it is still possible that others may have access to your files but this is mostly on how the hosting provider setup their servers.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文