Search code examples
phpapachealiasvirtual-server

what is the difference between virtual server and alias in apache for php?


normally, phpmyadmin is configured as alias in wamp packages and some of the projects can be configured in virtual server with port number. Can anybody explain what's the difference between these two and in which scenario any of the feature can be used?


Solution

  • Alias

    An "alias" in Apache can be a directory alias, i.e.

    Alias /phpmyadmin /usr/share/phpmyadmin
    

    this means you can use http://example.org/phpmyadmin/ and http://www2.example.org/phpmyadmin/ (every host on your apache instance) to access phpmyadmin.

    Virtual Host

    Virtual hosts are used to host multiple domains on a single apache instance. You can have one virtual host for each IP your server has, or the same IP but different ports, or the same IP, the same port but different host names. The latter are called "name based vhosts".

    Each virtual host is configured by itself and does not influence the other vhosts.

    There is also a ServerAlias directive which adds another name to the name based virtual host.