访问 DocumentRoot 之外的目录

访问 DocumentRoot 之外的目录

我最近使用以下方式将一个 Web 应用程序部署到我的 Linux Redhat 服务器上:卡皮斯特拉诺这会在站点的文档根目录中创建以下目录结构:

/var/www/html/example.com/releases/*
/var/www/html/example.com/current

为了在页面加载时加载当前目录,我更改了 httpd.conf,以便将 example.com 的 DirectoryRoot 设置为/var/www/html/example.com/current。问题是我希望某些目录可供浏览,这些目录位于“当前”目录之外(phpMyAdmin 和 Bugzilla)。我尝试touch将 .htaccess 文件设置为 ,/var/www/html/example.com但什么也没创建...

为了访问位于 DocumentRoot 之外的目录,我需要做什么?我是否应该更改 DocumentRoot 并使用 .htaccess 将 Web 浏览器转发到当前目录,或者有更好的方法吗?

另外,还有一个不太重要的问题:为某些服务使用特定端口是否明智?当我使用 cPanel 时,他们使用 :2082,而 WHM 使用 :2086。我可以在服务器上做类似的事情,让服务(phpMyAdmin 和 Bugzilla)更隐蔽一些吗?

答案1

你将需要使用别名授予对当前 DocumentRoot 之外的目录的访问权限。

Apache 的配置实际上相当好地自我记录。您可以使用别名/icons/作为示例:

# Aliases: Add here as many aliases as you need (with no limit). The format is
# Alias fakename realname
#
# Note that if you include a trailing / on fakename then the server will
# require it to be present in the URL.  So "/icons" isn't aliased in this
# example, only "/icons/".  If the fakename is slash-terminated, then the
# realname must also be slash terminated, and if the fakename omits the
# trailing slash, the realname must also omit it.
#
# We include the /icons/ alias for FancyIndexed directory listings.  If you
# do not use FancyIndexing, you may comment this out.
#
Alias /icons/ "/var/www/icons/"

<Directory "/var/www/icons">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

另外,还有一个不太重要的问题:为某些服务使用特定端口是否明智?当我使用 cPanel 时,他们使用 :2082,而 WHM 使用 :2086。我可以在服务器上做类似的事情,让服务(phpMyAdmin 和 Bugzilla)更隐蔽一些吗?

您可以,但这只是通过隐蔽性来实现的安全性,最好的办法是通过 SSL 为他们提供服务并要求提供用户名/密码组合。

相关内容