1

I have built a basic web server, and everything works fine. I have a external hard drive which I would like to add to my /var/www folder. How should I do this?

1 Answers1

1

The most logical answer to your question: I would consider to create a mountpoint /var/ pointing that disc. That way your whole /var/ will be on that disc. That is not adding it to the current /var/www/ though. If the current disc has lots of content in /var/ your new disc if filled with that content already. You could do that following this answer.

The 2nd option would be to create a symlink in /var/ to point to the new disc. That way you add the new disc to the current content. But it might spell trouble in the future: not everything seems to understand or to correctly interpret symlinks. Plus you are spreading out your /var/ over 2 discs. So if 1 of the discs breaks the other becomes useless...

To offer a possible better option since you asked "how should I do this": Apache2 (assuming you use this) works with virtualhosts. That kills the need to store web content in /var/ and you can store it anywhere you want by including a documentroot in any of the virtualhosts. The default one will point to /var/www/ . So you can mount your disc with a name you like (ie. /user27374/) and put your website content into that directory (./var/www/ on that disc). You can keep the current /var/, copy it all over to the new disc (ie /user27374/var/www/), create a 2nd virtualhost that points to this webroot and test your setup while the current one stays active.

Any of these can be used but the last one I consider the easiest with the least maintenance. But feel free to consider any of the options (or if someone else posts a different one their method :) ).

Mind though that an external disc is not the quickest when loading data and you will need to have it mounted always if you want to use the webserver.

Rinzwind
  • 309,379