如何为 PHP 设置私有文件夹包括用于本地测试和实时使用的文件。
这里有点菜鸟。这里可能有一个简单的解决方案 - 但我无法让它工作或创建一个非混乱的测试环境。这个问题可能在其他地方得到了部分答案,但我仍然很困惑——所以我要问。
Linux VPS 上的实时路径(vhosts 目录中有许多站点):
/var/www/vhosts/mysite.com/subdomains/mysubDomain/httpdocs/index.php /* the public, everyone can see web root directory */
我希望能够配置私有级别,包括文件夹:
/var/www/vhosts/mysite.com/subdomains/mySubdomain/includes/myincludes.php /*where I want the webserver only to read */
注意:我还想在上传后使用同级目录来移动私有文件。
在本地,我尝试在以下位置创建类似的结构:
C:\xampp\htdocs\mySubdomain\httpdocs
一个坏主意是将本地 vHosts 文件中的 DocumentRoot 设置为 mySubdomain 文件夹 - 但这会公开以下目录结构:
<img src=”/httpdocs/images/image.png">
- 并且在实时站点中是不可接受的。
在我的 XAMPP 测试服务器上,我已经设置了 vhosts 文件,为 mysite.local 创建以下内容
NameVirtualHost 127.0.0.1:80
<VirtualHost 127.0.0.1:80>
DocumentRoot C:/xampp/htdocs/
ServerName localhost
</VirtualHost>
<VirtualHost mysite.local>
DocumentRoot "C:/xampp/htdocs/mySubDomain/httpdocs"
ServerName mysite.local
<Directory "C:/xampp/htdocs/mysite" ></Directory>
</VirtualHost>
但是,我无法访问 mySubdomain 文件夹中的包含内容。
问题:
- 整个方法是否比“实时”级别文件夹(即 httpdocs/includes)中的 htaccess 提供任何真正的好处?我看到多个参考资料表明“低于公共”的存储将是更安全的文件和首选文件夹结构。
- 是包含路径和文档根设置吗?还有其他神奇和微妙的平衡设置吗?如何在 httpdocs(不是 htdocs 本地文件夹被标识为公共目录)的情况下创建本地测试访问?
- 奖金(以及新手赠品),如果可以在此配置中设置 DreamweaverCS5.5 以利用它的一些优秀功能(例如自动发现包含文件)以进行测试和浏览器检查。
Bit of a noob here. There is a probably a simple solution here - but I can’t get it to work or create a non-kludgey environment for testing. This may be answered in part elsewhere, but I'm still pulling hair out - so I'm going to ask.
The live path on a Linux VPS (with many sites in vhosts directory):
/var/www/vhosts/mysite.com/subdomains/mysubDomain/httpdocs/index.php /* the public, everyone can see web root directory */
I want to be able to configure a private level includes file folder:
/var/www/vhosts/mysite.com/subdomains/mySubdomain/includes/myincludes.php /*where I want the webserver only to read */
Note: I’d also like to use a same-level directory for moving private files after upload.
Locally, I’ve tried to create a similar structure at:
C:\xampp\htdocs\mySubdomain\httpdocs
One bad ideas is to set DocumentRoot in a local vHosts file to the mySubdomain folder – but that exposes the directory structure in things like:
<img src=”/httpdocs/images/image.png">
– and will not be acceptable in the live site.
On my XAMPP testing server, I’ve set up the vhosts file, for mysite.local to create the following
NameVirtualHost 127.0.0.1:80
<VirtualHost 127.0.0.1:80>
DocumentRoot C:/xampp/htdocs/
ServerName localhost
</VirtualHost>
<VirtualHost mysite.local>
DocumentRoot "C:/xampp/htdocs/mySubDomain/httpdocs"
ServerName mysite.local
<Directory "C:/xampp/htdocs/mysite" ></Directory>
</VirtualHost>
But, then I can't access my includes in the the mySubdomain folder.
Questions:
- Is this whole approach provide any real benefit over htaccess in ‘live’ level folders (ie httpdocs/includes)? I’ve seen multiple references that storage “below public” will be a more secure file and preferred folder structure.
- Is it includepath and the Document Root settings? Some other magic and delicate balance of settings? How does one create local testing access where the httpdocs(not the htdocs local folder is identified as the public directory?
- Bonus (and the noob giveaway), if it’s possible to setup DreamweaverCS5.5 in this config for leveraging some of it’s fine features(like auto-discovery of the includes file) for testing and browser checking.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
public/somebusinesslogic.php
,但不能下载private/somefilewithpasswords。 php
..htaccess
文件也可以在 Apache 上禁用,这取决于它的实际内容,可能需要一段时间才能注意到。public/somebusinesslogic.php
, but NOTprivate/somefilewithpasswords.php
..htaccess
files can also be disabled on Apache, which depending on the actual contents of it can take a while to notice.