nginx 安装

回复 收藏
本帖最后由 乐橙306 于 2016-4-8 13:48 编辑

参考文档
linux 源码安装nginx
http://www.cnblogs.com/zhoulf/archive/2013/02/09/2909653.html

  1. 安装说明
  2. 系统环境:CentOS 6.4
  3. 软件:nginx-1.9.12.tar.gz
  4. 安装方式:源码编译安装
  5. 安装位置:/opt/nginx
  6. 下载地址:http://nginx.org/en/download.html
  7. 1.yum 安装一些依赖包
  8. [root@niaoyun-101 tools]# yum install  pcre*  zlib*    gcc     openssl  openssl-devel  libxml*  libxslt*   gd-devel  GeoI GeoIP-data GeoIP-devel  perl-devel perl-ExtUtils-Embed  gcc-c++
  9. 2.创建目录  创建用户  
  10. [root@niaoyun-101 tools]# mkdir   -p  /opt/nginx
  11. [root@niaoyun-101 tools]# mkdir   -p  /opt/tools
  12. [root@niaoyun-101 tools]# groupadd  www
  13. [root@niaoyun-101 tools]# useradd  -g www www
  14. 3.编译
  15. [root@niaoyun-101 tools]#wget  http://nginx.org/download/nginx-1.9.12.tar.gz
  16. [root@niaoyun-101 tools]#tar zxf  nginx-1.9.12.tar.gz
  17. [root@niaoyun-101 tools]#cd  nginx-1.9.12
  18. [root@niaoyun-101 nginx-1.9.12]#  ./configure  --prefix=/opt/nginx   --user=www --group=www   --with-http_stub_status_module  --with-select_module --with-poll_module  --with-http_ssl_module  --with-http_realip_module    --with-http_geoip_module      --with-threads
  19. [root@niaoyun-101 nginx-1.9.12]# make
  20. [root@niaoyun-101 nginx-1.9.12]# make  install
  21. [root@niaoyun-101 nginx-1.9.12]# /opt/nginx/sbin/nginx -V
  22. 4.修改配置文件
  23. cd   /opt/nginx/conf/
  24. vi  nginx.conf
  25. mkdir    /opt/nginx/conf/vhosts
  26. cd   /opt/nginx/conf/vhosts
  27. vi  80port.conf
  28. 5.启动
  29. [root@niaoyun-101 nginx-1.9.12]# /opt/nginx/sbin/nginx
  30. [root@niaoyun-101 tools]# ps  -ef |  grep  nginx
  31. root      26050      1  0 18:16 ?        00:00:00 nginx: master process /opt/nginx/sbin/nginx
  32. www       26161  26050  0 18:28 ?        00:00:00 nginx: worker process
  33. root      26225  18824  0 18:35 pts/0    00:00:00 grep nginx
  34. [root@niaoyun-101 tools]# lsof  -i:80

2016-03-13 11:12 举报
已邀请:
0

乐橙306

赞同来自:

  1. [root@niaoyun-101 conf]# cat   nginx.conf
  2. error_log  logs/error.log  error ;
  3. pid logs/nginx.pid;
  4. user  www www;
  5. worker_processes  auto;
  6. worker_rlimit_nofile 65535;

  7. events {
  8.     use epoll;
  9.     worker_connections  65535;
  10. }


  11. http {
  12.     client_body_buffer_size 32k;
  13.     client_header_buffer_size 2k;
  14.     client_max_body_size 2m;

  15.     default_type application/octet-stream;
  16.     log_not_found off;
  17.     server_tokens off;
  18.     include       mime.types;
  19.     gzip on;
  20.     gzip_min_length  1k;
  21.     gzip_buffers     4 16k;
  22.     gzip_http_version 1.0;
  23.     gzip_comp_level 2;
  24.     gzip_types       text/plain text/css text/xml text/javascript application/x-javascript application/xml application/rss+xml application/xhtml+xml application/atom_xml;
  25.     gzip_vary on;
  26.     error_page   500 502 503 504 /50x.html;

  27. #    log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  28. #             '$status $upstream_response_time $request_time $body_bytes_sent '
  29. #             '"$http_referer" "$http_user_agent" "$http_x_forwarded_for" "$request_body" '
  30. #             '$scheme $upstream_addr';
  31.      log_format nginx_log    '$remote_addr"[$time_local]"$request"$status"$body_bytes_sent"'
  32.                             '$http_referer"$http_user_agent"$http_x_forwarded_for"'
  33.                             '$request_time"$upstream_addr"$host"$request_body';



  34.     include vhosts/*.conf;
  35.    
  36. }
  37. [root@niaoyun-101 conf]#
0

乐橙306

赞同来自:

  1. [root@niaoyun-101 vhosts]# cat  80port.conf
  2. server

  3. {
  4.     listen 80;
  5.     server_name localhost;
  6.     index index.html index.htm index.php;
  7.     root /opt/nginx/html;
  8. location /nginx_status
  9.    {
  10.       stub_status on;
  11.       access_log off;
  12.       allow 127.0.0.1;
  13.     # allow all;
  14.       deny all;
  15.    }
  16. }
  17. [root@niaoyun-101 vhosts]#
0

乐橙306

赞同来自:

本帖最后由 乐橙306 于 2016-4-8 13:49 编辑
  1. nginx编译参数:
  2. --prefix= 指向安装目录
  3. --sbin-path 指向(执行)程序文件(nginx)
  4. --conf-path= 指向配置文件(nginx.conf)
  5. --error-log-path= 指向错误日志目录
  6. --pid-path= 指向pid文件(nginx.pid)
  7. --lock-path= 指向lock文件(nginx.lock)(安装文件锁定,防止安装文件被别人利用,或自己误操作。)
  8. --user= 指定程序运行时的非特权用户
  9. --group= 指定程序运行时的非特权用户组
  10. --builddir= 指向编译目录
  11. --with-rtsig_module 启用rtsig模块支持(实时信号)
  12. --with-select_module 启用select模块支持(一种轮询模式,不推荐在高载环境下使用)禁用:--without-select_module
  13. --with-poll_module 启用poll模块支持(功能与select相同,与select特性相同,为一种轮询模式,不推荐在高载环境下使用)
  14. --with-file-aio 启用file aio支持(一种APL文件传输格式)
  15. --with-ipv6 启用ipv6支持
  16. --with-http_ssl_module 启用ngx_http_ssl_module支持(使支持https请求,需已安装openssl)
  17. --with-http_realip_module 启用ngx_http_realip_module支持(这个模块允许从请求标头更改客户端的IP地址值,默认为关)
  18. --with-debug 启用debug日志

回复帖子,请先登录注册

退出全屏模式 全屏模式 回复
评分
可选评分理由: