如何有效地在主 Web 目录之外运行脚本?
我有 Web-Developer Server Suite,带有 PHP 5.25,是从 SourceForge 下载的。 我的操作系统是Windows 7家庭版。
我已将 Apache 升级到最新版本,并将很快将 PHP 升级到 5.38。
除了一个小问题外,它运行良好;主 webroot 之外的虚拟主机 (C:/www/vhosts) 不显示 PHP 脚本,或者根本不显示任何脚本;只是简单的代码。所有虚拟主机都在 C:/www/vhosts 中工作,但不适用于我在 vhosts 中声明的任何其他位置。
其他位置是:
- C:/www/
- C:/www/vhosts-test/
- C:/www/businessweb/
- C:/www/newmediasite/public_html/
尽管我在 httpd-vhosts.conf 中声明了这些位置!
我如何让服务器理解主 webroot 之外的 PHP 以及 ASP.NET
(请记住我还添加了 mod_aspdotnet)。
我很乐意对此提出任何建议;刚刚花了一天半的时间重建我的网络服务器,在重新安装网络开发服务器套件(恕我直言,这对于初学者来说非常好)后从备份中移动文件(所有 PHP 和 MySQL)。
我不知道该去哪里,但我会补充一点,只是为了相关性,这严格来说是一个用于测试的开发服务器。
I have Web-Developer Server Suite, with PHP 5.25, which I downloaded from SourceForge.
My operating system is Windows 7 Home Edition.
I upgraded Apache to the latest version and will be upgrading PHP to 5.38 soon.
It works well, apart from one small problem; virtual hosts outside the main webroot
(C:/www/vhosts) do not display PHP scripts, or indeed any scripts at all; just the plain code. All virtualhosts work within C:/www/vhosts, but not any of the other locations I've declared in vhosts.
The other locations are:
- C:/www/
- C:/www/vhosts-test/
- C:/www/businessweb/
- C:/www/newmediasite/public_html/
This is despite the fact I declared the locations in httpd-vhosts.conf !
How would I get the server to understand PHP outside the main webroot, and also ASP.NET
(bear in mind I added mod_aspdotnet as well).
I'd gladly appreciate any advice on this; just spent a day-and-a-half rebuilding my webserver, moving files from a backup (all PHP and MySQL) after reinstalling Web-Developer Server Suite (which, IMHO, is pretty good for a beginner).
I'm not sure where to go with this, but I'll add, just for relevance, that this is strictly a development server for testing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以将脚本放置在 Webroot 之外的受保护目录中,这样访问者就无法访问它们。
但是,您需要在 Webroot 中放置一个包含这些脚本的脚本。大多数固件实现类似的功能。
据我了解,只有配置为 Webroot 的目录才能执行脚本。 Apache 已经添加了一个安全层,用于不在 Webroot 之外执行脚本。
因此,如果您的目标是保护某些脚本,您可以这样做,否则,我认为这是不可能的。
You can place your scripts in protected directory outside your Webroot so they are not accessible by your visitors.
However you need to place a script in your Webroot, that include these scripts. Most of the Firmwares implement a similar functionality.
As I understand, only the directory configured as Webroot will be able to execute scripts. Already Apache adds a security layer for not executing scripts outside Webroot.
So if your target is to protect some of your scripts, you can do that, otherwise, I don't think it's possible.
根据我对你的问题的理解,你希望能够将 PHP 文件放在计算机上的任何位置,但仍然能够执行。我不相信这是可能的,因为 PHP 文件是通过网络服务器打开的,即 127.0.0.1/foo.php 而不是 file://foo.php/
网络服务器配置为执行 /www 中的文件,除非有设置某个地方(我不知道)所有 PHP 脚本都必须放在 /www 中。
From my understanding of your question, you want to be able to have your PHP files anywhere on your computer, yet have them still be able to execute. I do not believe this is possible, as PHP files are opened through the webserver i.e 127.0.0.1/foo.php instead of file://foo.php/
The webserver is configured to execute the files in /www, unless there is a setting somewhere (which I am unaware of) all PHP scripts will have to rest in /www.