微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在我的本地PHP开发人员设置中设置DOCUMENT_ROOT和站点根目录?

我在网上做一个网站的工作.这是一个外星人的网站,我正在慢慢地通过奇怪的代码.我有MAMP本地,我的 http://localhost/有许多客户端文件夹从中脱离出来.在这代码中有很多$_SERVER [‘document_root’]命令和引用,这些命令和引用只是在我的本地PHP开发区域中丢失.

如何轻松地将document_root的引用设置为应该是什么(在本地,尽管如此,不要真的想弄乱网站文件,因为我需要再次上传它们,不想破坏实况网站!是否有一种间接设置的方式,PHP认为网站的根源是这样的图像的src引用“/ images / …”将正确显示…我的本地PHP开发网址是:http://localhost:8888/_CLIENTS/clientsite/www/ …但是在代码中’/’开头的’/ images / …’引用了http://localhost:8888/

谢谢.

我建议的是vhosts,所以您可以在本地提供“外来站点”,而不会影响您的认Web服务器.

> localhost – >你的起始页或者什么
> alien.localhost – >客户端站点,无论您想要的路径/文档根目录.
> x.localhost – >另一个网站

在apaches全局配置文件或包含vhost.conf;

NameVirtualHost localhost:80
# the MysqL tool's url
<VirtualHost PHPmyadmin.localhost:80>
# and absolute path
DocumentRoot "/srv/www/PHPMyAdmin/"
</VirtualHost>

#Same for the Client Site
<VirtualHost foo.localhost:80>
DocumentRoot "/path/to/desired/webroot/"
</VirtualHost>

您可以通过首先指定以下内容来控制权限并设置整体全局站点

在apache的全局服务器配置

DocumentRoot "/srv/www/htdocs"
#
# Configure the DocumentRoot Properties
#
<Directory "/srv/www/htdocs"> 
    Options All
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All","None",or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    AllowOverride All
    # Controls who can get stuff from this server.
    Order allow,deny
    Allow from all
</Directory>
#
# Configure Sub-Domain Properties. This prevents those nasty 403 errors
#

# MysqL administration tool
<Directory "/srv/www/PHPMyAdmin/">
    Options Indexes MultiViews
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

# a client web site built with CakePHP
<Directory "/home/eddie/workspace/Digital_Business/app/webroot/">
    Options All
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

原文地址:https://www.jb51.cc/php/139574.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐