As my knowledge about apache is minimal. I'd like to let it grow so I'd have more experience with LAMP. My hot question for today is:

How to add custom directory to webserver? (e.g. phpmyadmin)?

My goal is to be able to create custom addresses with custom websites within. Let's suppose that I have my custom directory at: /media/my/web/portal1 and I'd like to load it when client calls

http://localhost/myportal1 at webbrowser. 

Could you give me a list of steps with few words of explanation?

4 Answers 4


Edit your Apache config file and add an Alias Directive. For example, let's use the default file.

sudo -e /etc/apache2/sites-available/default

Make your alias by adding a section within the VirtualHost directive:

Alias /database/ "/usr/share/php5/phpmyadmin/"
<Directory "/usr/share/php5/phpmyadmin/">
    Order allow,deny
    Allow from all
    # New directive needed in Apache 2.4.3: 
    Require all granted

Save and restart: sudo /etc/init.d/apache2 restart

Or for the other reference:

sudo -e /etc/apache2/sites-available/default

And the contents...

Alias /myportal1/ "/media/my/web/portal1/"
<Directory "/media/my/web/portal1/">
    Order allow,deny
    Allow from all
    # New directive needed in Apache 2.4.3: 
    Require all granted

Save and restart: sudo /etc/init.d/apache2 restart

Add more directives within the Directory directives, such as

Options Indexes FollowSymLinks 

See http://httpd.apache.org/docs/2.2/mod/core.html#directory

That what you were after?

  • I think it is sufficient to reload apache after making those changes? Jan 2, 2012 at 1:23
  • Thanks Cristopher! That is just what I was looking for! :)
    – Darj
    Jan 2, 2012 at 9:52
  • I added this line insde the <Directory> section to prevent Forbidden errors, hopefully the edit will be accepted soon: Require all granted
    – Richard
    Nov 8, 2014 at 19:33
  • 3
    There is no need for appending an ending slash in the alias name. It forces the user to strictly type it to the URL. In such case, Alias /myportal1 other than Alias /myportal1/. Note missing ending slash. Feb 1, 2016 at 1:12

A simpler alternative is to create a soft link from the document root. For example, if the document root is "/var/www" (the default on most Linux systems), then the following command does the trick:

sudo ln -s /media/my/web/portal1 /var/www/myportal1

This works immediately - you don't even need to reload the Apache server.


Apache is a user in your system, just like you are, except that it cannot login. That means file access is exactly the same for Apache as it is for you. So, first, if Apache should serve a directory in /media/something, then Apache must have access to read it and its files.

Second, to setup a site that uses this directory as its home, you create sites-files, like /etc/apache2/sites-available/your-site. This is part of what's called vhosting. There are two different types; one based on name (the domain name) and one based on IP. The most common setup is to use name-based vhosts. You can read more about that here: http://httpd.apache.org/docs/2.2/vhosts/

  • Thanks for references. I will definatelly dig into this! :)
    – Darj
    Jan 2, 2012 at 9:53

So Simple in two lines :

sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.conf


just edit the file "phpmyadmin.conf"

pico /etc/apache2/conf.d/phpmyadmin.conf

and change it to 'loool' or whatever :)

Alias /loooool /usr/share/phpmyadmin

<Directory /usr/share/phpmyadmin>

SetEnvIfNoCase User-Agent "^ZmEu" bad_bot
SetEnvIfNoCase User-Agent "^BackDoorBot" bad_bot
SetEnvIfNoCase user-agent "^BlackWidow" bad_bot 
SetEnvIfNoCase User-Agent "^BotALot" bad_bot

after all of this reload apache :D

service apache2 reload

tadaaa :D ciao :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.