我是在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是自己在配置文件中定义的;

最新文章

  1. [教程] [承風雅傳HSU]用ES4封裝Win7---ES4 Win7封裝教程(未完待續)
  2. ios 重签名
  3. 转载《android:scaleType属性》
  4. 深度学习框架 Torch 7 问题笔记
  5. 【AdaBoost算法】弱分类器训练过程
  6. Java里面的转义字符
  7. 细解ListView之自定义适配器
  8. QT 初阶 第二章 创建对话框(查找对话框实例)
  9. centos6.6编译安装lnmp系列之mysql
  10. 【BZOJ】1878: [SDOI2009]HH的项链(树状数组)
  11. IT人才最容易犯的17个错误--人生警言
  12. ZooKeeper(3.4.5) - 原生 API 的简单示例
  13. UVa 1213 (01背包变形) Sum of Different Primes
  14. create Context Menu in Windows Forms application using C# z
  15. uva_12535 - Probability Through Experiments
  16. G++ 教程(转)
  17. OD: ActiveX Vulnerabilities
  18. setPixel抛出java.lang.IllegalStateException
  19. mysql回想一下基础知识
  20. Matlab中plot函数全功能解析

热门文章

  1. 【转】fedora和ubuntu开启ssh
  2. Android Studio 2.0 Beta 5公布,修复几个与即时执行相关的严重BUG.
  3. python中pymysql使用
  4. TraceTool 跟踪工具的瑞士军刀(C++版使用)
  5. Android中View绘制流程以及invalidate()等相关方法分析(转)
  6. Loadrunner IP欺骗
  7. Material Design (四),AppBarLayout的使用
  8. 淘宝数据库OceanBase SQL编译器部分 源码阅读--生成逻辑计划
  9. Nova镜像使用方法
  10. js之substr和substring的差别