Accessing directories outside of DocumentRoot
You are going to want to use an Alias to give access to directories outside you current DocumentRoot.
Apache's config is actually pretty well self-docuemnting. You can use the alias for /icons/
as an example:
# 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>
Also, as an unimportant side issue: is it wise to use a specific port for certain services? When I used cPanel, they used :2082 and WHM used :2086. Could I do a similar thing on my server to make the services (phpMyAdmin and Bugzilla) a little more hidden?
You could, but that's just security through obscurity you best bet is to serve them over SSL and require a username/password combination.
Related videos on Youtube
![hohner](https://i.stack.imgur.com/MGeAO.jpg?s=256&g=1)
hohner
Updated on September 18, 2022Comments
-
hohner almost 2 years
I've recently deployed a web application to my Linux Redhat server using Capistrano which creates the following directory structure in the site's document root:
/var/www/html/example.com/releases/* /var/www/html/example.com/current
In order to load the current directory on page load, I changed my httpd.conf so that example.com's DirectoryRoot was set to
/var/www/html/example.com/current
. The problem is that I want certain directories to be available for browsing which are outside the 'current' directory (phpMyAdmin and Bugzilla). I've triedtouch
ing a .htaccess file to/var/www/html/example.com
but nothing is created...What do I need to do in order to access directories which are located outside my DocumentRoot? Should I change the DocumentRoot and use .htaccess to forward the web browser to my current directory, or is there a better approach?
Also, as an unimportant side issue: is it wise to use a specific port for certain services? When I used cPanel, they used :2082 and WHM used :2086. Could I do a similar thing on my server to make the services (phpMyAdmin and Bugzilla) a little more hidden?
-
hohner over 12 yearsWorked perfectly, thanks. I'm a programmer by trade -- always been a bit reluctant to dabble with server configs, but this was actually quite easy. As you said, it's very well documented.
-
armyofda12mnkeys over 6 yearsinstead of setting up an apache Alias, could a dev just symlink to a folder outside of DocumentRoot before hand? like 'ln -s /uploaded_files /var/www/html/myproject/public/uploaded_files'