Is it okay to use symbolic links in my web server?

10,135

There's nothing wrong with that, as long as the apache process can read the files in your home directory.

If you're on a development machine, you could just as well put your files under the /var/www directory or a subdirectory thereof, but you can also edit /etc/apache2/sites-available/default so that the line with DocumentRoot points to your /home/tim/Website/files_here folder.

There's also mod_userdir, an apache module that permits files in /home/<username>/public_html to be served.

Share:
10,135
Tim
Author by

Tim

My name is Tim. I've graduated from the University of Nottingham with a First Class Computer Science BSc with Hons. In my spare time I do computer programming, often C or JavaScript, but also shell scripts, and answering questions on Stack Exchange. I used to spend most of my time on Ask Ubuntu; now I mostly browse the HNQ or Meta Stack Exchange. If you want to contact me it's [email protected] Do you need a reliable VPS? Try Digital Ocean. Sign up with this link for $10 free. One of my favourite sites is Kiva.org, a micro-funding organisation that allows people to lend money via the Internet to low-income entrepreneurs and students in over 80 countries. Kiva's mission is “to connect people through lending to alleviate poverty.” With just $25 you can make a difference - and 99% of loans are paid back in full - so you can lend again and again!

Updated on September 18, 2022

Comments

  • Tim
    Tim over 1 year

    I have the following directory setup:

    /var/www/html
    

    and

    /home/tim/Website/files_here
    

    The folder html is actually a link to /home/tim/Website. This means all my Website files are in my home area (they get included in the backup etc).

    Is there anything wrong with this method? Is there a better way to get the homepage to be in /home/tim/Website?

    Are symbolic links on a web server ever incompatible with users not on linux?

    • Dan
      Dan over 9 years
      Symlinks are somewhat bad practice on a web-server. There is a good explanation on Server Fault about this: serverfault.com/a/244612/66406. But, in your case, you are using the symbolic link on your root directory, so you can still have the FollowSymLinks option in apache disabled and it would still work. So that security problem wouldn't be an issue.