Saturday, April 6, 2019

How to Setup A Basic File server Using simpleHTTPserver

This brief tutorial describes how to setup a basic file server in minutes using simpleHTTPserver in Linux. This steps should work on any operating systems that supports python.

Install Python

You know how to install Python. It is available in the default repositories of almost all modern Linux operating systems.
On Arch Linux and its derivatives:
$ sudo pacman -S python
On Debian/Ubuntu and its derivatives, run the following command from the Terminal:
$ sudo apt-get install python
On RHEL/CentOS:
$ sudo yum install python
For Fedora:
$ sudo dnf install python
On SUSE/openSUSE:
$ sudo zypper in python
After installing Python, you need to do one more thing. Just run the following command from your Terminal to start the file server:
$ python -m SimpleHTTPServer
For python 3.0 and above versions, run:
$ python -m  http.server 8000
Sample output would be:
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ..
To stop the file server, just press CTRL+C.
To find Python version, run the following command:
$ python -V
Sample output:
Python 2.7.10
That’s it. File server is ready. Open the web browser and point it to http://IP-Address:8000
In case the port 8000 is blocked in your firewall, you have to open it.
For example, on RHEL/CentOS/Fedora, open port 8000 as shown below.
# firewall-cmd --permanent --add-port=8000/tcp
# firewall-cmd --reload
On Debian, Ubuntu you can allow the port as shown below.
$ sudo ufw allow 8000
Here it is how my local server’s contents looks in my browser.
Now, anyone in your local network can access your File server and it’s contents. Just set the permissions to your files and folders of your choice. You can then browse the contents from any local or remote systems as the way you do in any file server or website.

No comments:

Post a Comment