How to set up an HTTP based file server on CentOS 8

We can set up an apache HTTP based file server on Linux using python. Let’s take a look at how to set up an HTTP based file server on CentOS 8.

How to set up an HTTP based file server on CentOS 8

We can set up a basic httpd file server on CentOS 8/7. you just need to install python on Linux. Use the command to install different versions like python36, python, python2, etc.

sudo yum install python38 -y

After installing python, check your python version using the python3 –version command.

[[email protected] ~]# python3 --version
Python 3.8.0

We will create some sample files and save them in a directory. Use the following commands.

[[email protected] ~]# mkdir httpfile
[[email protected] ~]# touch file{1,2,3,4}
[[email protected] ~]# mv file* httpfile/
[[email protected] ~]# ls httpfile/
file1 file2 file3 file4

Open port 8000 in firewall rules.

[[email protected] ~]# firewall-cmd --permanent --add-port=8000/tcp
[[email protected] ~]# firewall-cmd --reload

Method 1:

Using python:

You need to install the simplehttpdserver module in Linux using the following commands according to your python version.

[[email protected] ~]# cd httpfile/
[[email protected] httpfile]# python3 -m http.server
Serving HTTP on port 8000 (

Note Use http.server for python 3 version and SimpleHTTPServer for python or python 2 versions.

python -m SimpleHTTPSever  or python2 -m SimpleHTTPSever

As you can see, the HTTP file server is running on port 8000 and you can access the directory from any IP address using the port number. It will only be a list of data.

You can also use different ports to configure the HTTP file server with the following command. we can also bind a specific IP address.

python3 -m http.server 8080                                                ## использовать другой порт
python3 -m http.server 8080 --bind

Method 2:

File server using Ruby:

We can also set up a file server using ruby. you must have Ruby installed on your computer.

sudo yum install ruby ​​-y

Check ruby ​​version using below command.

[[email protected] ~]# ruby -v
ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux]

Use the command below to create a Ruby based HTTP server with port 8000.

[[email protected] httpfile]# ruby -run -ehttpd . -p8000
[2020-09-05 02:20:55] INFO WEBrick 1.4.2
[2020-09-05 02:20:55] INFO ruby 2.5.5 (2019-03-15) [x86_64-linux]
[2020-09-05 02:20:55] INFO WEBrick::HTTPServer#start: pid=2482 port=8000

You can access the file server using the URL http: // ip: 8000.

Method 3:

File server using HTTP server (Nodejs):

We have another method for a file server using nodejs. you need to install nodejs on your computer.

sudo yum install nodejs -y

After installing nodejs, we need to install the http-server package using the following command.

[[email protected] httpfile]# npm install -g http-server
/usr/local/bin/http-server -> /usr/local/lib/node_modules/http-server/bin/http-server
/usr/local/bin/hs -> /usr/local/lib/node_modules/http-server/bin/http-server
+ [email protected]
added 23 packages from 35 contributors in 8.396s

Start the file server using the below command with port 8000.

[[email protected]]# cd httpfile
[[email protected] httpfile]# http-server -p 8000
Starting up http-server, serving ./
Available on:
Hit CTRL-C to stop the server

Check the url from http: // ip: 8000.

We have successfully shown you how to create an https based file server using apache on Linux.

That’s all.