Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

apache alias vs symbolic link

Tags:

symlink

apache

When working with apache on a unix system,

If your file system has icons in /home/me/web/icons

and you want the browser be able to display them when calling the url http://www.me.com/icons/myicon.jpg for example,

then you have at least 2 solutions :

alias ( Alias /icons/ /home/web/icons/ )

symbolic links ( ln -s /home/web/icons /home/me/web/www/icons )

It seems to me that using apache aliases is the best choice since we know exactly that aliases would normally be in the /etc/apache2 directory ( so that is just one place to look at in case the application grows ), but I would be pleased to know about what solution you use and why ?

like image 976
ling Avatar asked Jul 03 '11 06:07

ling


People also ask

What is the difference between a symbolic link and an alias?

Answer: A symbolic link, aka soft link or symlink, is a special kind of file that points to another file. A shell alias allows a string to be substituted for a word when it is used as the first word of a simple command.

What is Alias in Apache?

The Alias directive allows documents to be stored in the local filesystem other than under the DocumentRoot . URLs with a (%-decoded) path beginning with URL-path will be mapped to local files beginning with directory-path . The URL-path is case-sensitive, even on case-insensitive file systems.

What is the point of symlinks?

A symlink is a symbolic Linux/ UNIX link that points to another file or folder on your computer, or a connected file system. This is similar to a Windows shortcut. Symlinks can take two forms: Soft links are similar to shortcuts, and can point to another file or directory in any file system.

Is symbolic link same as soft link?

A soft link (also known as Symbolic link) acts as a pointer or a reference to the file name. It does not access the data available in the original file. If the earlier file is deleted, the soft link will be pointing to a file that does not exist anymore.


2 Answers

Using an Alias in your Apache httpd has several advantages over using a symbolic link:

  • Symbolic links require an additional disk access to resolve the symbolic link.
  • Alias works on all platforms supported by Apache httpd. Symbolic links are not supported by all platforms and filesystems.
  • Your Apache httpd configuration will work the exactly same way on a new system without the need to create symbolic links in your file system.
like image 80
joschi Avatar answered Sep 21 '22 06:09

joschi


With shared hosting you are not authorized to alter the Apache config, so a symlink is an alternative.

like image 28
jin_hcc Avatar answered Sep 20 '22 06:09

jin_hcc