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
安装环境:
Centos-6.3 x64
安装方式:
源码编译安装
安装位置:
/usr/local/nginx
下载nginx:
nginx-1.6.1.tar.gzc++
yum -y install gcc-c++ yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel
cd /usr/local wget http://nginx.org/download/nginx-1.6.1.tar.gz tar zxvf nginx-1.6.1.tar.gz mv nginx-1.6.1 nginx cd /usr/local/nginx ./configure --prefix=/usr/local/nginx make make install
#运行用户 user nginx; #启动进程,一般设置成和cpu的数量相等 worker_processes 1; #全局错误日志及PID文件 error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { #单个后台worker process进程的最大并发连接数 worker_connections 1024; } #设定http服务器 http { #设定mime类型,类型由mime.type文件定义 include /etc/nginx/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 /var/log/nginx/access.log main; #sendfile 指令指定 nginx 是否调用 sendfile 函数(zero copy 方式)来输出文件,对于普通应用, #必须设为 on,若是用来进行下载等应用磁盘IO重负载应用,可设置为 off,以平衡磁盘与网络I/O处理速度,下降系统的uptime. sendfile on; #tcp_nopush on; #链接超时时间 keepalive_timeout 65; #开启gzip压缩 gzip on; #包含的配置文件 include /etc/nginx/conf.d/*.conf; }