Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question

4 Answers 4

up vote 7 down vote accepted

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
</Directory>

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
</Directory>

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?

share|improve this answer
    
I think it is sufficient to reload apache after making those changes? –  Jo-Erlend Schinstad Jan 2 '12 at 1:23
    
oh - yes... thanks Jo-Erland Schinstad –  user8290 Jan 2 '12 at 1:36
    
Thanks Cristopher! That is just what I was looking for! :) –  Adrian K. Jan 2 '12 at 9:52

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/

share|improve this answer
    
Thanks for references. I will definatelly dig into this! :) –  Adrian K. Jan 2 '12 at 9:53

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.

share|improve this answer

So Simple in two lines :

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

After

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 :)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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