Learning and Sharing
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
No Result
View All Result

How to Setup a HTTP File Server in Ubuntu

November 16, 2022
in Blog, Linux
0
ADVERTISEMENT

Table of Contents

There are many way to share file on network. Mostly use network file sharing is CIFS and SAMBA. In this article we will discuss how we can perform file share over HTTP using Apache2 Web server file sharing on a Linux machine using distro Ubuntu. Using HTTP to download file is just like download file from some website which looks cool.

Setting up Apache2 Web server File Sharing

1. At first check your Linux machine OS version using command cat /etc/os-release, in my case it’s Ubuntu 20.

# cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.4 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.4 LTS"
VERSION_ID="20.04"

2. Download and install Apache2 Web server for Web server File Sharing using the following comand:

sudo apt install apache2 -y

3. Once done, you can check the /var/www/html directory which contains default HTML page.

# ls -l /var/www/html/
total 16
-rw-r--r-- 1 root root 10918 Nov 16 10:04 index.html

4. Check if your Apache2 Web server is working by opening web browser and open default HTML page by typing the ip address of the Ubuntu machine in the address bar which should open a page as below:

5. Create a sub folder under html folder to store the public data.

mkdir /var/www/htlm/public

6. Now, using any FTP client to upload public files to the public folder on Ubuntu server.

# ls -l /var/www/html/public/
total 704824
-rw-r--r-- 1 root root 525508520 Nov  7 11:12 AcrobatPro_11_Web_WWMUI.exe
-rw-r--r-- 1 root root   3999808 Nov 15 08:30 AnyDesk.exe
-rw-r--r-- 1 root root 165841568 Nov 10 02:09 ExpanDrive_Setup_2022.7.1.exe
-rw-r--r-- 1 root root   1395272 Nov  2 01:05 rufus-3.20p.exe
-rw-r--r-- 1 root root   2132264 Nov 10 01:55 VisualStudioSetup.exe
-rw-r--r-- 1 root root  11377992 Nov 15 06:27 VNC-Viewer-6.22.826-Windows.exe
-rw-r--r-- 1 root root  11471704 Nov  1 07:18 WinSCP-5.21.5-Setup.exe

Create a virtual host for the http file server

1. Run the following command to disable the default site. If you don’t do this, when you access by typing ip address on the browser. It’s always show the default Apache welcome page.

sudo a2dissite 000-default

2. Create a virtual host configuration file. You can change the file name public.conf and the DocumentRoot /var/www/html/public to any directory as you need.

cat << EOF >> /etc/apache2/sites-available/public.conf
<VirtualHost *:80>

	ServerAdmin webmaster@localhost
	DocumentRoot /var/www/html/public

	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined
  
</VirtualHost>
EOF

3. Verify the virtual host is created in /etc/apache2/sites-available directory.

# ls -l /etc/apache2/sites-available/
total 16
-rw-r--r-- 1 root root 1332 Feb 23  2021 000-default.conf
-rw-r--r-- 1 root root 6338 Feb 23  2021 default-ssl.conf
-rw-r--r-- 1 root root  156 Nov 16 10:32 public.conf

4. Finally, enable the virtual host, test Apache configuration then reload Apache service.

sudo a2ensite public
sudo apache2ctl configtest
sudo systemctl reload apache2

As you can see, now the public http file server available to access from any computer in your network though any web browser.

Configure the HTTP file share with a domain name

Access the file shared via ip address look like not professional. And I want to access the file server through a domain name like http://files.bonguides.com.

To achieve that goal, I need:

  • A DNS server to resolve the host name to the IP address of the Ubuntu server. It could be a public DNS when you bought a domain or a local DNS in Microsoft Active Directory, or you can create a DNS record in some routers and firewalls.
  • Create a new virtual host with server name.

1. Remove the current virtual host configuration file.

rm /etc/apache2/sites-available/public.conf

2. Recreate the virtual host configuration file as follows:

cat << EOF >> /etc/apache2/sites-available/public.conf
<VirtualHost *:80>
    ServerName files.bonguides.com
    ServerAlias www.files.bonguides.com
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/public
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
EOF

3. Now, you can access the HTTP file server though a domain name instead of ip address.

ADVERTISEMENT
5/5 - (1 vote)
Previous Post

Make a Bootable Windows 10 USB Drive from a Mac with Terminal

Next Post

How to Change the Account Picture on Your MacBook

Related Posts

Running Hyper-V and VMware Workstation on The Same Machine

August 15, 2024

How to Uninstall All Autodesk Products At Once Silently

July 29, 2024
Ftr5

How to Uninstall the Autodesk Genuine Service on Windows

July 29, 2024
Ftr19

How to Fix Windows Cannot Read the ProductKey From the Unattend Answer File in VirtualBox

July 26, 2024
Ftr25

How to Update Windows Terminal in Windows 10/11

July 26, 2024

How to Disable The Beep Sound in WSL Terminal on Windows

July 26, 2024

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • How To Turn On uBlock Origin Extension in Chrome (2025)
  • Images Hidden Due To Mature Content Settings In CivitAI
  • Azure OpenAI vs Azure AI Hub, How to Choose the Right One for Your Needs

Categories

Stay in Touch

Discord Server

Join the Discord server with the site members for all questions and discussions.

Telegram Community

Jump in Telegram server. Ask questions and discuss everything with the site members.

Youtube Channel

Watch more videos, learning and sharing with Leo ❤❤❤. Sharing to be better.

Newsletter

Join the movement and receive our weekly Tech related newsletter. It’s Free.

General

Microsoft Windows

Microsoft Office

VMware

VirtualBox

Technology

PowerShell

Microsoft 365

Microsoft Teams

Email Servers

Copyright 2025 © All rights Reserved. Design by Leo with ❤

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory