nginx介绍和源码安装

     
Nginx ("engine x") 是一个高性能的 HTTP 和  反向代理 服务器,也是一个 IMAP/POP3/SMTP  服务器。 Nginx 是由 Igor Sysoev 为俄罗斯访问量第二的 Rambler.ru 站点开发的,第一个公开版本0.1.0发布于2004年10月4日。其将 源代码以类BSD许可证的形式发布,因它的稳定性、丰富的功能集、示例配置文件和低系统资源的消耗而闻名。2011年6月1日,nginx 1.0.4发布。
Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,并在一个BSD-like 协议下发行。由俄罗斯的程序设计师Igor Sysoev所开发,供俄国大型的入口网站及搜索引擎Rambler(俄文:Рамблер)使用。其特点是占有内存少, 并发能力强,事实上nginx的并发能力确实在同类型的网页服务器中表现较好,中国大陆使用nginx网站用户有:新浪、 网易、腾讯等。

        nginx由于功能强大,高负载低内存消耗,支持高并发,稳定等性能已经被越来越多的公司作为web解决方案。
        我自己的总结下nginx的用途
             1.最主要的还是用作web服务器,以快速稳定而闻名,完全可以单挑http了。
             2.负载均衡器,作为优秀的七层负载均衡器,能实现对应用层的负载和转移,包括对地址的重定向,url重写等强大功能,而且作为负载均衡器配,占用网络资源相当小(配置比起lvs简单好几个数量级),加上配合keepalived等可以免除单点故障实现高可用。
             3.其实他还是一款优秀的电子邮件代理服务器和反向代理服务器(翻墙技术。。)只是在国内用的少。
             4.在前端完全可以全部采用nginx实现部署。
 
          首先来看下nginx安装吧,安装也是相当的简单。
           进官网下载最新稳定版   http://nginx.org/download/nginx-1.8.0.tar.gz
           操作系统 CENTOS6.5
              
              下载软件  wget http://nginx.org/download/nginx-1.8.0.tar.gz
               

            只有813k大小   
            解压 tar -xvf nginx-1.8.0.tar.gz  
             

点击(此处)折叠或打开

  1. ./configure --help

  2.   --help print this message

  3.   --prefix=PATH set installation prefix
  4.   --sbin-path=PATH set nginx binary pathname
  5.   --conf-path=PATH set nginx.conf pathname
  6.   --error-log-path=PATH set error log pathname
  7.   --pid-path=PATH set nginx.pid pathname
  8.   --lock-path=PATH set nginx.lock pathname

  9.   --user=USER set non-privileged user for
  10.                                      worker processes
  11.   --group=GROUP set non-privileged group for
  12.                                      worker processes

  13.   --build=NAME set build name
  14.   --builddir=DIR set build directory

  15.   --with-rtsig_module enable rtsig module
  16.   --with-select_module enable select module
  17.   --without-select_module disable select module
  18.   --with-poll_module enable poll module
  19.   --without-poll_module disable poll module

  20.   --with-threads enable thread pool support

  21.   --with-file-aio enable file AIO support
  22.   --with-ipv6 enable IPv6 support

  23.   --with-http_ssl_module enable ngx_http_ssl_module
  24.   --with-http_spdy_module enable ngx_http_spdy_module
  25.   --with-http_realip_module enable ngx_http_realip_module
  26.   --with-http_addition_module enable ngx_http_addition_module
  27.   --with-http_xslt_module enable ngx_http_xslt_module
  28.   --with-http_image_filter_module enable ngx_http_image_filter_module
  29.   --with-http_geoip_module enable ngx_http_geoip_module
  30.   --with-http_sub_module enable ngx_http_sub_module
  31.   --with-http_dav_module enable ngx_http_dav_module
  32.   --with-http_flv_module enable ngx_http_flv_module
  33.   --with-http_mp4_module enable ngx_http_mp4_module
  34.   --with-http_gunzip_module enable ngx_http_gunzip_module
  35.   --with-http_gzip_static_module enable ngx_http_gzip_static_module
  36.   --with-http_auth_request_module enable ngx_http_auth_request_module
  37.   --with-http_random_index_module enable ngx_http_random_index_module
  38.   --with-http_secure_link_module enable ngx_http_secure_link_module
  39.   --with-http_degradation_module enable ngx_http_degradation_module
  40.   --with-http_stub_status_module enable ngx_http_stub_status_module

  41.   --without-http_charset_module disable ngx_http_charset_module
  42.   --without-http_gzip_module disable ngx_http_gzip_module
  43.   --without-http_ssi_module disable ngx_http_ssi_module
  44.   --without-http_userid_module disable ngx_http_userid_module
  45.   --without-http_access_module disable ngx_http_access_module
  46.   --without-http_auth_basic_module disable ngx_http_auth_basic_module
  47.   --without-http_autoindex_module disable ngx_http_autoindex_module
  48.   --without-http_geo_module disable ngx_http_geo_module
  49.   --without-http_map_module disable ngx_http_map_module
  50.   --without-http_split_clients_module disable ngx_http_split_clients_module
  51.   --without-http_referer_module disable ngx_http_referer_module
  52.   --without-http_rewrite_module disable ngx_http_rewrite_module
  53.   --without-http_proxy_module disable ngx_http_proxy_module
  54.   --without-http_fastcgi_module disable ngx_http_fastcgi_module
  55.   --without-http_uwsgi_module disable ngx_http_uwsgi_module
  56.   --without-http_scgi_module disable ngx_http_scgi_module
  57.   --without-http_memcached_module disable ngx_http_memcached_module
  58.   --without-http_limit_conn_module disable ngx_http_limit_conn_module
  59.   --without-http_limit_req_module disable ngx_http_limit_req_module
  60.   --without-http_empty_gif_module disable ngx_http_empty_gif_module
  61.   --without-http_browser_module disable ngx_http_browser_module
  62.   --without-http_upstream_hash_module
  63.                                      disable ngx_http_upstream_hash_module
  64.   --without-http_upstream_ip_hash_module
  65.                                      disable ngx_http_upstream_ip_hash_module
  66.   --without-http_upstream_least_conn_module
  67.                                      disable ngx_http_upstream_least_conn_module
  68.   --without-http_upstream_keepalive_module
  69.                                      disable ngx_http_upstream_keepalive_module

  70.   --with-http_perl_module enable ngx_http_perl_module
  71.   --with-perl_modules_path=PATH set Perl modules path
  72.   --with-perl=PATH set perl binary pathname

  73.   --http-log-path=PATH set http access log pathname
  74.   --http-client-body-temp-path=PATH set path to store
  75.                                      http client request body temporary files
  76.   --http-proxy-temp-path=PATH set path to store
  77.                                      http proxy temporary files
  78.   --http-fastcgi-temp-path=PATH set path to store
  79.                                      http fastcgi temporary files
  80.   --http-uwsgi-temp-path=PATH set path to store
  81.                                      http uwsgi temporary files
  82.   --http-scgi-temp-path=PATH set path to store
  83.                                      http scgi temporary files

  84.   --without-http disable HTTP server
  85.   --without-http-cache disable HTTP cache

  86.   --with-mail enable POP3/IMAP4/SMTP proxy module
  87.   --with-mail_ssl_module enable ngx_mail_ssl_module
  88.   --without-mail_pop3_module disable ngx_mail_pop3_module
  89.   --without-mail_imap_module disable ngx_mail_imap_module
  90.   --without-mail_smtp_module disable ngx_mail_smtp_module

  91.   --with-google_perftools_module enable ngx_google_perftools_module
  92.   --with-cpp_test_module enable ngx_cpp_test_module

  93.   --add-module=PATH enable an external module

  94.   --with-cc=PATH set C compiler pathname
  95.   --with-cpp=PATH set C preprocessor pathname
  96.   --with-cc-opt=OPTIONS set additional C compiler options
  97.   --with-ld-opt=OPTIONS set additional linker options
  98.   --with-cpu-opt=CPU build for the specified CPU, valid values:
  99.                                      pentium, pentiumpro, pentium3, pentium4,
  100.                                      athlon, opteron, sparc32, sparc64, ppc64

  101.   --without-pcre disable PCRE library usage
  102.   --with-pcre force PCRE library usage
  103.   --with-pcre=DIR set path to PCRE library sources
  104.   --with-pcre-opt=OPTIONS set additional build options for PCRE
  105.   --with-pcre-jit build PCRE with JIT compilation support

  106.   --with-md5=DIR set path to md5 library sources
  107.   --with-md5-opt=OPTIONS set additional build options for md5
  108.   --with-md5-asm use md5 assembler sources

  109.   --with-sha1=DIR set path to sha1 library sources
  110.   --with-sha1-opt=OPTIONS set additional build options for sha1
  111.   --with-sha1-asm use sha1 assembler sources

  112.   --with-zlib=DIR set path to zlib library sources
  113.   --with-zlib-opt=OPTIONS set additional build options for zlib
  114.   --with-zlib-asm=CPU use zlib assembler sources optimized
  115.                                      for the specified CPU, valid values:
  116.                                      pentium, pentiumpro

  117.   --with-libatomic force libatomic_ops library usage
  118.   --with-libatomic=DIR set path to libatomic_ops library sources

  119.   --with-openssl=DIR set path to OpenSSL library sources
  120.   --with-openssl-opt=OPTIONS set additional build options for OpenSSL

  121.   --with-debug enable debug logging
   编译第一步  ./configure --help 查看可使用参数,可以自己选择增删模块,自己选择安装路径
  ./configure --prefix=/usr/local/nginx/
     由于我是测试用,具体的模块自己选择,我就用最简单的默认模式了。。。
     ./configure: error: the HTTP rewrite module requires the PCRE library.
   报错。。。。找不到pcre依赖库
        使用yum install pcre-devel -y 安装,如果源码安装的要指定pcre目录
        这样缺少什么就安装什么,另外我安装的时候要手动指定下zlib库,rpm -ql zlib 查看所在目录
        编译成功了就是make && make install 了
            
        nginx目录:client_body_temp  conf  fastcgi_temp  html  logs  proxy_temp  sbin  scgi_temp  uwsgi_temp
        主目录是sbin  ,logs,html,conf。 
       sbin目录下是nginx的二进制程序,用来启动nginx
       logs下存放nginx一些相关目录,可以有配置文件指定
       html 下存放具体的页面文件,类似tomcat的webapps目录,可以由配置文件指定。
       conf目录下是配置文件
       启动nginx   /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf   启动时指定配置文件
     
        查看端口netstat -tunlp    
        tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      2840/nginx         
         
          80端口启动成功
            到此nginx成功安装。         
   








评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值