How to set up a simple file server?
you are talking about a file server with apache
Just do as follows.
Open your terminal and do as below
sudo apt-get install apache2
then
sudo service apache2 start
Just open your browser and type as localhost and press enter.
If you see
You have installed your webserver successfully.
Now we have to setup a file server for you.
Now open /var/www/html
location and make a folder with any name and place some files of yours.
Then restart/reload apche2 and then in the browser type as
localhost/ and you see your folders.
But to make your friends/people to see your files. we have a lot of work to do like
- We need a website name for that
- If no website name then we have to choose one and add it in your /etc/hosts file and your friends /etc/hosts file.
- Make a virtualhost entry in
/etc/apache2/apache2.conf
file
I'm not sure the phrasing of the question specifically denotes whether your aim is to share files over the internet or around a private network. I'll add that if you want to share files over a private network with apache you can install and start apache, as described previously, remove the default index.html, and add files to the /var/www/html directory. To others on your private network they will be able to navigate to your device IP address on the network (192.168.###.###) and access any files in the /var/www/html directory.
Presuming port forwarding on 80 on your router proxying external internet traffic is not configured at all/not configured to forward to your device, your files will not be accessible to the public internet. Only folks on your private network will be able to access the files in /var/www/html .
Once more, in commands:
Install Apache:
sudo apt-get install apache2
Start Apache:
sudo service apache2 start
Remove index.html from /var/www/html:
sudo rm /var/www/html/index.html
Copy your files to /var/www/html:
sudo cp /path/to/file /var/www/html/[insert new file name]
Copy a whole directory!!
sudo cp -r /path/to/directory /var/www/html/[insert new directory name]
This might be obvious, but it's worth saying this should work even if your connection to the public internet is down. Use case: Let's say, the internet at your workplace is down because of an ISP maintenance mess up and isn't expected to come back up for an hour or two, but your coworker has a bunch of files you need that you'd usually get via a public internet resource (dropbox, npm, etc.). If you have apache installed already you could share files between each other in this way.
Security-wise, obviously these files are available to anyone on your private network. Whatever you share in this way you should be comfortable with everyone on your private network having. The traffic isn't encrypted either (i.e. it's served over HTTP, not HTTPS). I hadn't thought if malicious smart devices might be scanning other devices to see if they have anything running on port 80. They could grab whatever they find and send to an external source. So that's not great. Beware!
Hope this helps!