1. nginx安装

Env: Mac OS 10.10 Yosemite

pcre: http://pcre.org/

  1. $tar -zxf pcre-8.34.tar.gz
  2. $cd pcre-8.34
  3. $./configure
  4. $make
  5. $sudo make install

zlib: http://zlib.net/

  1. $tar -zxf zlib-1.2..tar.gz
  2. $cd zlib-1.2.8
    $./configure
    $make
    $sudo make install

openssl: http://www.openssl.org/source/

  1. $tar -zxf openssl-1.0.1j.tar.gz
  2. $cd openssl-1.0.1j
  3. $./config

注意下此时会有提示要编译64位版本需要用另外的指令

  1. WARNING! If you wish to build -bit library, then you have to
  2.  
  3. invoke './Configure darwin64-x86_64-cc' *manually*.
  4.  
  5. You have about seconds to press Ctrl-C to abort.
  1. $make clean
  2. $./Configure darwin64-x86_64-cc
  3. $make
  4. $sudo make install

nginx: http://nginx.org/en/download.html

  1. $tar -zxf nginx-1.7..tar.gz
  2. $cd nginx-1.7.
  3. $./configure --with-http_ssl_module
  4. $make
  5. $sudo make install

安装完毕,/usr/local/nginx为服务器安装目录

  1. $cd /usr/local/nginx
  2. $ls
  3. conf html logs sbin

conf为服务器配置目录,编辑nginx.conf启用各种模块

html为网站文件目录,存放html/js/css等文件

sbin为nginx可执行文件,

  1. $./sbin/nginx -h
  2. nginx version: nginx/1.7.
  3. Usage: nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives]
  4.  
  5. Options:
  6. -?,-h : this help
  7. -v : show version and exit
  8. -V : show version and configure options then exit
  9. -t : test configuration and exit
  10. -q : suppress non-error messages during configuration testing
  11. -s signal : send signal to a master process: stop, quit, reopen, reload
  12. -p prefix : set prefix path (default: /usr/local/nginx/)
  13. -c filename : set configuration file (default: conf/nginx.conf)
  14. -g directives : set global directives out of configuration file

启动nginx服务器: sudo /usr/local/nginx/sbin/nginx

这时候打开浏览器输入http://localhost/能显示Welcome to nginx!表示配置成功

停止、重启等操作通过-s参数,例如修改配置后重启:sudo /usr/local/nginx/sbin/nginx -s reload

2. nginx启用gzip压缩

参数设置可参考http://www.cnblogs.com/dasn/articles/4043989.html

其中gzip_types可参照nginx/conf/mime.types的映射进行设置,比apache方便不少

例如:

  1. gzip on;
  2. gzip_types text/plain text/html text/xml application/javascript application/json;
  3. gzip_comp_level ;
  4. gzip_http_version 1.0;

3. nginx缓存时间控制

expires [time|epoch|max|off]

默认off

time: 可为正负数,负数表示永远过期

epoch: 指定为1 January, 1970, 00:00:01 GMT

max: 指定为31 December 2037 23:59:59 GMT

例如:

  1. location ~ \.(jpg|ico|png|jpeg|js|json|html|txt)$ {
  2. expires 30d;
  3. }

nginx搭建笔记的更多相关文章

  1. Nginx 笔记(四)nginx 原理与优化参数配置 与 nginx 搭建高可用集群

    个人博客网:https://wushaopei.github.io/    (你想要这里多有) 一.nginx 原理与优化参数配置 ​ ​ master-workers 的机制的好处 首先,对于每个 ...

  2. 21.TFS文件系统搭建笔记

    TFS文件系统搭建笔记 参考地址: https://github.com/alibaba/tfs/blob/master/INSTALL.md https://github.com/alibaba/t ...

  3. Nginx学习笔记~目录索引

    回到占占推荐博客索引 前几天整理了<Docker的学习笔记索引>,受到了很多朋友的关注,今天把Nginx的文章也整理一下,以后将永久更新,像大叔之前的<EF文章系列>,< ...

  4. 转:Linux下使用Nginx搭建简单图片服务器

    最近经常有人问图片上传怎么做,有哪些方案做比较好,也看到过有关于上传图片的做法,但是都不是最好的,今天再这里简单讲一下Nginx实现上传图片以及图片服务器的大致理念. 如果是个人项目或者企业小项目,仅 ...

  5. 用nginx搭建http/rtmp/hls协议的MP4/FLV流媒体服务器

    前前后后搭建了两三个星期,终于可以告一段落,nginx实在是有点强大.写一篇笔记来记录一下这个过程中的思路和解决方案. 一.搭建nginx平台: 基本是基于http://blog.csdn.net/x ...

  6. nginx 搭建图片服务器(windows 下,linux 下原理应该一样)

    作者的心声:很多知道的.用过的东西,不写下来,下次还要百度查询,浪费时间和精力,故本次写下学习笔记,方便下次查阅. 题外话:如有读者通过我这篇博客解决了工作上的难题,可以给个评论,让我一起分享你的喜悦 ...

  7. 正向代理与反向代理的区别【Nginx读书笔记】(zz)

    正向代理与反向代理的区别[Nginx读书笔记]       正向代理的概念 正向代理,也就是传说中的代理,他的工作原理就像一个跳板,简单的说,我是一个用户,我访问不了某网站,但是我能访问一个代理服务器 ...

  8. nginx搭建http和rtmp协议的流媒体服务器

    nginx搭建http和rtmp协议的流媒体服务器 时间:2013-09-23 23:52来源:佚名 作者:本站 举报 点击:232次 实验目的:让Nginx支持flv和mp4格式文件,同时支持Rtm ...

  9. Nginx搭建flv视频点播服务器

    Nginx搭建flv视频点播服务器 前一段时间使用Nginx搭建的多媒体服务器只能在缓冲过的时间区域内拖放, 而不能拖放到未缓冲的地方. 这就带来了一个问题: 如果视频限速的速率很小, 那么客户端观看 ...

随机推荐

  1. BeanUtils.populate的作用

    它是在org.apache.commons.beanutils.BeanUtils包中的一个方法. 方法的作用:将一些 key-value 的值(例如 hashmap)映射到 bean 中的属性.   ...

  2. 修改C# 新建类模板

    找到安装路径下的这个文件夹:D:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ItemTemplatesCache\CSh ...

  3. Jmail发送邮件

    注册jmail windows --> 运行 --> cmd --> cd jmail目录 --> regsvr32 jmail.dll --> 注册成功 public ...

  4. Java处理Excel整理篇

    常用Excel,每次写的时候都得现查,索性做一个整理. Java里用的时候一般用jxl这个包,相对好用. 读: File file = new File(excelFile);Workbook boo ...

  5. MYBATIS 文档

    http://www.mybatis.org/mybatis-3/zh/index.html

  6. Device nodes and device stacks

    [Device nodes and device stacks] 链接:https://msdn.microsoft.com/en-us/library/windows/hardware/ff5547 ...

  7. CentOS 安装rz和sz命令

    虚机装了CentOS7.2最小版本, 结果上去后发现rz命令不能用 yum install lrzsz  安装完成:

  8. XdbxAnalysis

    Tree: TXdbxAnalysis; FDataStream: TMemoryStream; {FDataStream:= TMemoryStream.Create;    FDataStream ...

  9. java查看当前项目所有线程列表界面

    java查看当前项目所有线程列表界面 1.TestThread(测试类) package com.isoftstone.pcis.isc.job.king.panel; public class Te ...

  10. KVO

    •基本概念 Key Value Observing, 键值观察者.它提供一种机制,当指定的对象的属性被修改后,则对象就会接收到通知. 与NSNotification不同,键值观察中并没有中心对象来为所 ...