nginx安装

1
$ sudo apt install nginx
  • 开机自启
1
systemctl enable nginx.service
  • 启动/重启/停止/查看状态 nginx
1
systemctl start/restart/stop/status nginx.service
  • 查看nginx版本

下面的三种方法均可查看nginx的版本

1
2
3
$ nginx -v	# 显示简要信息
$ nginx -V # 显示详细信息
$ curl -i localhost
  • 启动nginx
1
systemctl start nginx.service
  • 直接ip访问确定nginx是否正常启动

出现上图字样表示nginx正常运行

nginx代理FTP服务器

  • 配置FTP访问服务

参照之前这篇文章:

ubuntu云服务器搭建FTP环境

  • 修改nginx配置文件
1
vim /etc/nginx/nginx.conf

nginx.confhttp块中添加如下内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
server{
listen 8080; # 监听端口,一定要在防火墙开放该端口
server_name localhost; # 映射名称,ip访

location / {
alias /home/ftp/lyj/; # FTP服务器文件夹
autoindex on; # 打开文件目录列表
index lyj; # 设置欢迎页
autoindex_exact_size on;# 显示文件大小,单位字节
autoindex_localtime on; # 显示时间
charset utf-8,gbk; # 设置编码格式防止中文乱码

}
}

  • 重启nginx服务
1
systemctl restart nginx.service
  • 浏览器访问ip:8080即可访问FTP服务的文件夹

参考:

Nginx代理FTP服务器