加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

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

发布时间:2020-12-13 14:01:36 所属栏目:PHP教程 来源:网络整理
导读:我在网上做一个网站的工作.这是一个外星人的网站,我正在慢慢地通过奇怪的代码.我有MAMP本地,我的 http://localhost/有许多客户端文件夹从中脱离出来.在这段代码中有很多$_SERVER [‘document_root’]命令和引用,这些命令和引用只是在我的本地PHP开发区域中丢
我在网上做一个网站的工作.这是一个外星人的网站,我正在慢慢地通过奇怪的代码.我有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>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读