This is an optional step in that you do not have to have a USB drive but you can use one to store your web site files leaving the SD card for the Debian or Ubuntu operating system. Also a USB Drive should be faster than the SD card.
We could use a more conventional external Hard Disk Drive but you have to be aware that you may need to power it using an external power source.
To use a USB flash drive we have to format it, mount it and then configure Apache to use the required folder instead of the default folder.
This procedure will work on Debian or Ubuntu systems.
WARNING: DELETING partitions, MODIFYING and FORMATTING filesystems destroys data so double check you are working with the USB Drive.
Plug the drive into a USB port and then in the terminal window type:
This will list all the storage devices. One will be the SD card which will look something like dev/mmcblko and the other one will be the USB drive which will probably be dev/sda1 although yours may be different.
First, we have to format the USB drive which in my case is:
DO CHECK THE DRIVE IDENTIFICATION AS IT MAY BE DIFFERENT ON YOUR INSTALLATION.
Now create a directory name for the files:
Now we mount the drive using the new directory name:
and then create a subfolder under websites using:
and another using:
It will be this folder were we place our web files.
Check the ownership of the files by:
You will need to change the ownership at some stage to allow uploads to the folder. This is explained in the section that describes uploading with FileZilla.
We now have to set up mounting when the Raspberry Pi is rebooted by editing “/etc/fstab”:
In this file we need to add a new line at the bottom, separating each item with a tab.
To exit the editor, press Ctrl+X to exit, Y then Enter to save.
Now, if the Raspberry Pi is rebooted, the USB flash drive will be mounted.