nginx编译安装

来源:互联网 发布:初音未来眼药水 淘宝 编辑:程序博客网 时间:2024/06/04 23:26

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

下载nginx软件包http://nginx.org/en/download.html下载地址

[ root@anuuy ~]# tar xf  nginx-1.6.2.tar.gz[ root@anuuy ~]# yum -y groupinstall  "development tools"   | yum -y install pcre-devel   | yum -y install openssl-devel #安装一些依赖包[ root@anuuy ~]# cd nginx-1.6.2 #进入安装包解压的目录./configure  \--prefix=/usr/local/nginx \--conf-path=/etc/nginx/nginx.conf  \--user=nginx \--group=nginx \--error-log-path=/var/log/nginx/error.log \--http-log-path=/var/log/nginx/access.log \--pid-path=/var/run/nginx/nginx.pid \--lock-path=/var/lock/nginx.lock  \--with-http_ssl_module \--with-http_stub_status_module \--with-http_gzip_static_module \--with-http_flv_module \--with-http_mp4_module \--http-client-body-temp-path=/var/tmp/nginx/client \--http-proxy-temp-path=/var/tmp/nginx/proxy \--http-fastcgi-temp-path=/var/tmp/nginx/fastcgi \--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \--with-debug \

模块解释:

 --prefix=/etc/nginx #指明nginx程序文件安装路径--conf-path=/etc/nginx/nginx.conf #主配置文件安装位置--error-log-path=/var/log/nginx/error.log #错误日志文件安装位置 --http-log-path=/var/log/nginx/access.log #访问日志文件安装位置--pid-path=/var/run/nginx.pid#指定pid文件安装位置--lock-path=/var/run/nginx.lock #锁文件安装位置--http-client-body-temp- path=/var/cache/nginx/client_temp #客户端body部分的临时 文件存放路径,如果服务器允许客户端使用put方法提交大数据 时,临时存放的磁盘路径 --http-proxy-temp-path=/var/cache/nginx/proxy_temp #代理服务器响应报文的临时文件存放路径--http-fastcgi-temp- path=/var/cache/nginx/fastcgi_temp #作为fastcgi代理服务器,服务器响应报文的临时文件存放路径 --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp #作为uwsgi代理服务器,服务器响应报文的临时文件存放路径#作为 scgi反代服务器,服务器响应报文的临时文件存放路径--user=nginx #指明以那个身份运行worker进程,主控master 进程一般由root运行--group=nginx--with-http_ssl_module #ssl加密协议模块

编译安装

[ root@anuuy ~]# make && make install #开始编译安装     

创建nginx用户和组

[ root@anuuy ~]# useradd -g nginx -r nginx[ root@anuuy ~]# groupadd -r nginx

创建模块目录

[ root@anuuy ~]# mkdir -pv /var/tmp/nginx/{client,proxy,fastcgi,uwsgi}   #之前编译时写了很多模块指定了目录,这里需要创建

主配置文件介绍

[ root@anuuy ~]# vim /etc/nginx/nginx.conf    #nginx主配置文件路径# For more information on configuration, see:#   * Official English Documentation: http://nginx.org/en/docs/#   * Official Russian Documentation: http://nginx.org/ru/docs/user nginx;  #以那个用户运行nginxworker_processes auto;  #worker进程的数量;通常应该为当前主机的cpu的物理核心数 error_log /var/log/nginx/error.log;   #错误日志路径pid /var/run/nginx.pid;   #进程id文件# Load dynamic modules. See /usr/share/nginx/README.dynamic.include /usr/share/nginx/modules/*.conf;  #模块配置文件路径events {    worker_connections  1024;  #每个worker进程所能打开的最大并发连接数数量}http {    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            on;    tcp_nopush          on;    tcp_nodelay         on;    keepalive_timeout   65;    types_hash_max_size 2048;    include             /etc/nginx/mime.types;    default_type        application/octet-stream;    # Load modular configuration files from the /etc/nginx/conf.d directory.    # See http://nginx.org/en/docs/ngx_core_module.html#include    # for more information.    include /etc/nginx/conf.d/*.conf;}

ok!

原创粉丝点击