我是在Windows上安装的,在Linux上也一样

#Windows server2008 R2

#Nginx1.12

Nginx安装包下载地址:http://nginx.org/en/download.html

一、安装、启动Nginx

1、下载进行解压,将解压后的文件放到某目录下;

2、进入window的cmd窗口,进入到nginx目录,使用“start nginx.exe ”启动Nginx;

3、启动成功后,在“任务管理器”中会看到“nginx.exe”进程;

4、在浏览器地址栏输入:127.0.0.1 会看到nginx的欢迎界面;

  相关命令:   

    start nginx.exe     //启动
    nginx.exe -s stop      //停止nginx
    nginx.exe -s reload   //重新加载nginx
    nginx.exe -s quit     //退出nginx

以上步骤很简单;

二、配置为文件服务器

1、配置文件服务器,其实主要是改配置文件就行了;

  如果Nginx在启动状态,先停止;

2、下面l贴出整个配置文件内容:

#nginx.conf

#user nobody;
worker_processes 1;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;

events {
  worker_connections 1024;
}

http {
  include mime.types;
  default_type application/octet-stream;

  #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  # '$status $body_bytes_sent "$http_referer" '
  # '"$http_user_agent" "$http_x_forwarded_for"';

  #access_log logs/access.log main;

  sendfile on;
  #tcp_nopush on;

  #keepalive_timeout 0;
  keepalive_timeout 65;

  #gzip on;

  server {
    listen 80;
    server_name localhost;

    #charset koi8-r;

    #access_log logs/host.access.log main;

    location / {
      root html;
      index index.html index.htm;
    }

    #error_page 404 /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
      root html;
    }
    

    #增加以下几行即可
    location /data {
      alias E:\data;         #共享目录
      allow all;           #都允许
      autoindex_exact_size on;     # 显示文件大小
      autoindex_localtime on;     # 显示文件时间
      autoindex on;        # 显示目录
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    # proxy_pass http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    # root html;
    # fastcgi_pass 127.0.0.1:9000;
    # fastcgi_index index.php;
    # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
    # include fastcgi_params;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    # deny all;
    #}
    }

    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    # listen 8000;
    # listen somename:8080;
    # server_name somename alias another.alias;

    # location / {
    # root html;
    # index index.html index.htm;
    # }
    #}

    # HTTPS server
    #
    #server {
    # listen 443 ssl;
    # server_name localhost;

    # ssl_certificate cert.pem;
    # ssl_certificate_key cert.key;

    # ssl_session_cache shared:SSL:1m;
    # ssl_session_timeout 5m;

    # ssl_ciphers HIGH:!aNULL:!MD5;
    # ssl_prefer_server_ciphers on;

    # location / {
    # root html;
    # index index.html index.htm;
    # }

  #}

}

3、改完配置文件,启动nginx, 用浏览器访问  http://ip/data    即可,此处ip为Nginx服务器的ip,/data是自己在配置文件中定义的;

安装Nginx作为文件服务器的更多相关文章

  1. CentOS 6.3安装Nginx 搭建文件服务器

    转自:http://www.linuxidc.com/Linux/2012-09/70596.htm 1.配置CentOS 6.2 第三方yum源(CentOS默认的标准源里没有nginx软件包): ...

  2. Windows Server2012上使用Nginx做文件服务器

    由于项目中用到了大量的文件上传和删除,考虑到安全的因素,所以整体的思路是使用FTP从主服务器把文件资源上传到文件服务器上. FTP上传到服务器的代码如下(简单附加一下,具体的网上很多) public ...

  3. linux环境手动编译安装Nginx实践过程 附异常解决

    1.下载nginx源码包并解压 可在http://nginx.org/en/download.html下载.tar.gz的源码包,如(nginx-1.4.7.tar.gz) 或者使用云盘下载   ht ...

  4. 安装配置fastDFS文件服务器 - Linux

    一.配置linux环境 1.新建虚拟机 把上次安装的CentOS7的文件复制一份,并改名 打开VM>打开虚拟机,选择刚才复制好的虚拟机,并启动.这样做的目的主要是为了保留一份最基础的母本,为了将 ...

  5. Ubuntu 14.04TLS和CentOS-6(64bit)上安装Nginx

    Ubuntu 14.04上安装Nginx [参考地址]https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on- ...

  6. nginx映射文件服务器文件夹

    nginx映射文件服务器文件夹 普通用户A安装的nginx,yum源搭建文件服务器,新建普通用户B,其主目录是文件服务器需要访问的目录 普通用户A启动nginx无法访问B用户的文件服务器目录,提示40 ...

  7. 转: 构建基于Nginx的文件服务器思路与实现

    在Web项目中使用独立的服务器来保存文件和图片的好处很多,如:便于统一管理,分流web服务器的压力,可进行访问加速等.另外当web服务器需要做集群进行负载均衡时,图片和文件上传在各个服务器之间同步将是 ...

  8. linux安装nginx 并配置文件服务器和代理服务器

    linux安装nginx搭建服务并实现文件服务器和代理服务器配置 1.课题的背景和意义 由于编码过程中需要进行文件上传服务,文件上传后 需要有http资源的路径需要访问.原则上可以通过Apache . ...

  9. centos直接yum安装nginx

    Ubuntu下安装nginx,直接apt-get install nginx就行了,很方便. 但是今天装了CentOS6.2,直接yum install nginx不行,要先处理下源,下面是安装完整流 ...

随机推荐

  1. [转]PHP并发IO编程之路(深度长文)

    原文:https://www.imooc.com/article/8449 -------------------------------------------------------------- ...

  2. weex 阶段总结

    新年伊始,回顾过去的一年,收获很多,之前一直在研究weex,说心里话感觉心好累,官方文档不全,社区不活跃,遇到很多坑,官方发布的版本有时都有坑,搞得我都不敢更新版本了. 但是,研究了这么久,放弃太可惜 ...

  3. Android使用procrank和dumpsys meminfo 、top分析内存占用情况

    如果你想查看所有进程的内存使用情况,可以使用命令procrank.dumpsys meminfo查看,当然也只可以过滤出某个进程如:dumpsys meminfo | grep -i phone 先来 ...

  4. iOS开发之---判断是否是手机号

    iOS开发之---判断是否是手机号

  5. 01背包+卡精度 Hdu 2955

    <span style="color:#3333ff;">/* ---------------------------------------------------- ...

  6. LeetCode(26)题解:Remove Duplicates from Sorted Array

    https://leetcode.com/problems/remove-duplicates-from-sorted-array/ Given a sorted array, remove the ...

  7. cocoapods导入框架出错 The dependency `FMDB` is not used in any concrete target

    问题描述: The dependency `FMDB` is not used in any concrete target 解决办法: 官网是这样给推荐的: 在创建Podfile的时候,用这种格式使 ...

  8. DRF 之 版本控制

    1.版本控制是干什么用的,为什么要有版本? 我们都知道每一个程序都是有版本的.而且版本也会升级从v1升级到v2.v3.v4·····,但是我们不可能因为新版本出现旧版本就不去维护,因为用户有权选择不更 ...

  9. asp.net+access实现DropDownList与RadDatePicker同步筛选

    这里没有使用SqlServer是因为老师要求使用access. 前台代码 <table style="margin:auto"> <tr><td cl ...

  10. A JavaScript library for reading EXIF meta data from image files.

    exif-js/exif-js: JavaScript library for reading EXIF image metadata https://github.com/exif-js/exif- ...