Ok, so I am a n00b. Keep that in mind. My Ubuntu computer is running an Apache2 server for basic web hosting and file transfer. If I wanted to use an external hard drive for it, how would I go about it? I mean, the var, www, and html folders are stored in the computer's storage. I want to combine the storage from the internal computer and external drive for total storage for the /var/www
-
You want the /var/www on the external drive? Read stackoverflow.com/questions/5891802/…– s3lphJun 10, 2015 at 11:53
-
Or you want to add files to /var/www from the external drive? Please clarify.– Elder GeekJun 10, 2015 at 11:54
-
@the_Seppi Nope. I want to combine the storage from the internal computer and external drive for total storage for the /var/www– Mr. LeopoldJun 10, 2015 at 12:06
-
@ElderGeek I want to combine the storage from the internal computer and external drive for total storage for the /var/www– Mr. LeopoldJun 10, 2015 at 12:07
-
In future please edit your question to add clarifying information. I've done it for you this time.– Elder GeekJun 10, 2015 at 12:38
2 Answers
- You should mount the drive and make sure it mounts automatically after a restart.
- You can use a symlink to the folder on the external drive. You could link directly in the vhost or apache config, but using symlinks simplifies most of the time.
- You need to set proper rights so Apache can write to that folder. On Ubuntu, Apache is run as user www-data, so make sure www-data can write to that folder.
-
I am sorry but I am a n00b. Can you please explain what this would do? (Because there has been confusion on what my goal is; check the comments in the original post. I clarified there.) Jun 10, 2015 at 12:08
-
Mounting means that the drive is accessible by the OS. It's like the drive-letter in Windows, which can change for a given USB drive. This can change for Ubuntu as well, so you should make sure that this won't happen. Google for mounting external drives! Symlinks are pointers that point to another location on your disk or on another disk. You can replace the www in /var/www with a symlink to /var/www in the external drive. First solve (1) for this! (3) Change rights with chmod and chown commands. Google those as well!– SPRBRNJun 10, 2015 at 15:40
-
this is the correct command to give : sudo mount -o defaults /dev/sda1 /var/www/html and not this : sudo mount -o defaults /dev/yourdrivepartition /var/www/yourfolder. In other words,"yourfolder" should be called exactly "html".– MariettoMay 31, 2021 at 23:47
I specify beforehand that I have absolutely no experience with Apache
Having said that you might want to do the following
Before connecting the external drive
sudo fdisk -l
Repeat the above command after connecting the drive
You will see a new entry in the output (probably at the end). Observe the device
column of this entry. This is the block file that represents your drive. It will be something like /dev/yourdrivesfile .
Now make a folder in /var/www
and then mount the drive on it by:
sudo mount -o defaults /dev/yourdrivesfile /var/www/yourfolder
Before you do this try learning about the mount command and its options, you might need them. man mount
and info mount
will also help.
Changing permissions of your folder to allow www-data
(Apache) to write to it might be something like sudo chown www-data /var/www/yourfolder
, though I 'm not sure about this part.
Hope this helps with the mounting atleast.