In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "how to immediately set up a static file server in linux", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to set up a static file server in linux" this article.
Have you ever wanted to share your files or projects over the Internet, but you don't know how to do it? Don't worry! Here is a simple utility called serve that allows you to share your files instantly over the Internet. This simple utility immediately turns your system into a static file server, allowing you to provide files over the network. You can access these files from any device without worrying about their operating system. All you need is a Web browser. This utility can also be used to serve static websites. It used to be called "list" or "micri-list", but now its name has been changed to "serve" (provided), which is better suited to the purpose of this utility.
Use Serve to set up a static file server
To install serve, you first need to install NodeJS and NPM. Refer to the link below to install NodeJS and NPM in Linux.
How to install NodeJS on Linux
After the installation of NodeJS and NPM is complete, run the following command to install serve:
$npm install-g serve
Done! Now it's time to serve files or folders.
The typical syntax for using serve is:
$serve [options] provides specific files or folders
For example, let's share the contents of the Documents directory. To do this, run:
$serve Documents/
Sample output:
As you can see in the figure above, the contents of a given directory are already supported on the network through two URL.
To access content from your local system, simply open a Web browser and type URL http://localhost:5000/:
The serve utility displays the contents of a given directory in a simple layout. You can download (right-click the file and select "Save Link as …" Or view them only in the browser
If you want to open the local address automatically in the browser, use the-o option.
$serve-o Documents/
After running the above command, the serve utility automatically opens a Web browser and displays the contents of the shared item.
Similarly, to access a shared directory from a remote system over the network, enter http://192.168.43.192:5000 in the browser address bar. Replace 192.168.43.192 with your system's IP.
Content is provided through different ports
You may have noticed that by default, the serve utility uses port 5000. Therefore, make sure that port 5000 is allowed in the firewall or router. If it is blocked for some reason, you can use the-p option to use a different port to provide content.
$serve-p 1234 Documents/
The above command will provide the contents of the Documents directory through port 1234.
To provide a file instead of a folder, just give it the full path, as shown below.
$serve Documents/Papers/notes.txt
As long as you know the path, any user on the network can access the contents of the shared directory.
Provide the entire $HOME directory
Open terminal input
$serve
This will share the contents of the entire $HOME directory over the network.
To stop sharing, press CTRL+C.
Provide the selected file or folder
You may not want to share all the files or directories, just some of them. You can use the-I option to exclude files or directories.
$serve-I Downloads/
The above command will provide the entire file system except the Downloads directory.
Content is available only on the local host
Sometimes you just want to provide content on the local system rather than the entire network. To do this, use the-l flag, as follows:
$serve-l Documents/
This command provides the Documents directory locally only.
This can be useful when you are working on a shared server. All users in the system can access the share, but remote users cannot.
Use SSL to provide content
Because we provide content over the local network, we do not need to use SSL. However, the serve utility can use the-ssl option to share content using SSL.
$serve-ssl Documents/
To access the share through a Web browser, enter https://localhost:5000 or https://ip:5000.
Provide content through authentication
In all the above examples, we provide content without any authentication, so anyone on the network can access the shared content without any authentication. You may feel that you should use a user name and password to access something.
To do this, use:
$SERVE_USER=ostechnix SERVE_PASSWORD=123456 serve-auth
Now the user needs to enter a user name (that is, ostechnix) and a password (123456) to access the share. (LCTT Note: 123456 is a very bad password, used only in experimental situations.)
The serve utility also has some other features, such as disabling Gzip compression, setting CORS headers to allow requests from any river source, preventing addresses from being automatically copied to the clipboard, and so on. You can read the complete help section with the following command.
The above $serve help is all the contents of the article "how to set up a static file server in linux immediately". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.