搭建简单的文件下载服务器

[apache2]

1
2
3
4
5
6
7
8
9
$ root@user: apt-getinstall apache2  //配置文件地址 /etc/apache2/sites-enabled/000-default

$ root@user: cd /var/www/html/ //并在此目录放入要下载的文件

$ root@user: rm -f index.html //删除该文件

$ root@user: curl cip.cc //获取服务器外网IP 通过浏览器访问 如图

$ root@user: /etc/init.d/apache2 restart //重启Apache2 $ root@user: /etc/init.d/apache2 stop //停止Apache2

image

[Nginx]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
$ root@user: apt-getinstall nginx  //配置文件地址 /etc/nginx/nginx.conf  在nginx.conf末尾有一句:include /etc/nginx/conf.d/*.conf;  推荐把用户自己的配置放到conf.d/

$ root@user: vim /etc/nginx/conf.d/default.conf //添加用户的自定义配置文件
autoindex on;# 显示目录
autoindex_exact_size on;# 显示文件大小
autoindex_localtime on;# 显示文件时间
$ root@user: vim /etc/nginx/nginx.conf //在http 增加以下配置

server {
listen 8080 default_server;
listen [::]:8080 default_server;
server_name _;
root /root/share/; //分项目录

# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;

location / {
}

error_page 404 /404.html;
location = /40x.html {
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
}

}

$ root@user: /etc/init.d/nginx reload 重新加载

$ root@user: curl cip.cc //获取服务器外网IP 通过浏览器访问 如图


错误日志 /var/log/nginx/error.log
访问日志 /var/log/nginx/access.log

image