Linux 如何为服务器上的文件创建可下载的公共链接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10956587/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to create a downloadable public link for files on server
提问by Ensom Hodder
I am afraid my question could be very stupid, and also be duplicate. But I didn't manage to find what I want after looking for some similar questions on this site.
恐怕我的问题可能很愚蠢,而且是重复的。但是在这个网站上寻找了一些类似的问题后,我没有设法找到我想要的。
My question is simple, I have a big file, i.e. 1GB on my Ubuntu server, and I want to share this file with other users. How can I create a URL address for public users, in other words, when one user click this URL, the download will automatically start without demanding a username and password, just like we download many stuff (pdf, music) when we find an usable url with google.
我的问题很简单,我的 Ubuntu 服务器上有一个大文件,即 1GB,我想与其他用户共享这个文件。我如何为公共用户创建一个 URL 地址,换句话说,当一个用户点击这个 URL 时,下载将自动开始而不需要用户名和密码,就像我们在找到可用的时候下载很多东西(pdf、音乐)一样谷歌网址。
Someone suggests me to setup an anonymous ftp. I think it's a possible solution, but I didn't succeed to accomplish it. Can some one give me more details how I achieve my goal, (with or without ftp will both ok).
有人建议我设置一个匿名 ftp。我认为这是一个可能的解决方案,但我没有成功完成它。有人可以给我更多的细节,我如何实现我的目标,(有或没有 ftp 都可以)。
Thanks for any help, and I am very grateful for some examples, or some tutorials !
感谢您的帮助,我非常感谢一些示例或一些教程!
采纳答案by Igor Azevedo
Install Apache2
安装Apache2
sudo apt-get install apache2
Place your into file the /var/www/ directory (might need root privileges for this)
将您的文件放入 /var/www/ 目录(可能需要 root 权限)
sudo cp yourfile /var/www/yourfile
Access the file with the following link:
使用以下链接访问该文件:
http://your-ip-address/yourfile
If your running under a router or firewall, you might have to open port 80 and forward it to your pc.
如果您在路由器或防火墙下运行,您可能需要打开端口 80 并将其转发到您的电脑。
回答by xbonez
Lets assume your filename is foobar.iso
.
让我们假设您的文件名是foobar.iso
.
You could just place it in your web root, and give the link example.com/foobar.iso
to people. This will download the file.
你可以把它放在你的网络根目录中,然后把链接example.com/foobar.iso
给别人。这将下载文件。
Optionally, place it in a directory downloads
. The download link will then be example.com/downloads/foobar.iso
.
(可选)将其放在目录中downloads
。下载链接将是example.com/downloads/foobar.iso
。