nginx安装讲解

一、nginx编译安装
1、openresty编译安装

cd /soft/package/src/ngx_openresty-1.11.2.2
./configure \
--user=www \
--group=www \
--prefix=/soft/openresty-1.11 \
--pid-path=/soft/openresty-1.11/nginx/pid \
--error-log-path=/soft/log/nginx/error.log \
--http-log-path=/soft/log/nginx/access.log \
--http-proxy-temp-path=/soft/openresty-1.11/nginx/proxy_temp \
--http-fastcgi-temp-path=/soft/openresty-1.11/nginx/fastcgi_temp \
--http-client-body-temp-path=/soft/openresty-1.11/nginx/client_body_temp \
--with-openssl=/soft/package/src/openssl-1.0.2d \
--with-pcre=/soft/package/src/pcre-8.37 \
--with-libdrizzle=/usr/local \
--with-threads \
--with-file-aio \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_ssl_module \
--with-http_xslt_module \
--with-http_iconv_module \
--with-http_geoip_module \
--with-http_realip_module \
--with-http_gunzip_module \
--with-http_drizzle_module \
--with-http_addition_module \
--with-http_gzip_static_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-http_random_index_module \
--with-http_image_filter_module \
--without-http_uwsgi_module \
--without-http_scgi_module \
--with-mail \
--with-mail_ssl_module \
--add-module=/soft/package/src/ngx_3rd/nginx-accesskey-master/ \
--add-module=/soft/package/src/ngx_3rd/ngx_http_consistent_hash-master/ \
--add-module=/soft/package/src/ngx_3rd/nginx-static-etags-master/ \
--add-module=/soft/package/src/ngx_3rd/nginx-http-footer-filter-master/ \
--add-module=/soft/package/src/ngx_3rd/ngx_http_accounting_module-master/ \
--add-module=/soft/package/src/ngx_3rd/ngx_log_if-master/ \
--add-module=/soft/package/src/ngx_3rd/nginx-http-concat-master/ \
--add-module=/soft/package/src/ngx_3rd/nginx-module-vts-master/ \
--add-module=/soft/package/src/ngx_3rd/nginx-module-url-master/  \
--add-module=/soft/package/src/ngx_3rd/nginx-access-plus-master/src/c/
gmake && gmake install && ln -s /soft/openresty-1.11  /soft/openresty 

2、nginx编译参数

编译选项	                                                         作用
--prefix=/etc/nginx	                                      程序安装目录和路径
--sbin-path=/usr/sbin/nginx	                              Nginx启动停止命令
--modules-path=/usr/lib64/nginx/modules	                      Nginx模块路径
--conf-path=/etc/nginx/nginx.conf	                      Nginx主配置文件路径
--error-log-path=/var/log/nginx/error.log	              Nginx错误日志路径
--http-log-path=/var/log/nginx/access.log	              Nginx访问日志路径
--pid-path=/var/run/nginx.pid	                              NginxPid路径
--lock-path=/var/run/nginx.lock	                              Nginx锁路径
--http-client-body-temp-path=/var/cache/nginx/client_temp     client头部临时缓存文件
--http-proxy-temp-path=/var/cache/nginx/proxy_temp	      proxy临时缓存文件
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp	      fastcgi临时缓存文件
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp	      uwsgi临时缓存文件
--http-scgi-temp-path=/var/cache/nginx/scgi_temp	      scgi临时缓存文件
--user=nginx	                                             设定Nginx进程启动用户
--group=nginx	                                             设定Nginx进程启动组(安全)
--with-cc-opt	                                             设置额外的参数将被添加到CFLAGS变量
--with-ld-opt	                                             设置附加的参数, 链接系统库

3、nginx安装目录
[root@master~]# rpm -ql nginx

nginx安装目录
4、nginx常用模块

Nginx编译选项	                         模块作用
ngx_http_core_module	            包含一些核心的http参数配置,对应Nginx的配置区块部分
ngx_http_access_module	            访问控制模块,用来控制网站用户对Nginx的访问
ngx_http_gzip_module	            压缩模块,对Nginx返回的数据压缩,属于性能优化模块
ngx_http_fastcgi_module	            fastci模块,和动态应用相关的模块,例如PHP
ngx_http_proxy_module	            proxy代理模块
ngx_http_upstream_module	    负载均衡模块,可以实现网站的负载均衡功能及节点的健康检查。
ngx_http_rewrite_module             URL地址重写模块
ngx_http_limit_conn_module	    限制用户并发连接数及请求数模块
ngx_http_limit_req_module	    限制Nginx request processing rate根据定义的key
ngx_http_log_module	            访问日志模块,以指定的格式记录Nginx客户访问日志等信息
ngx_http_auth_basic_module	    Web认证模块,设置Web用户通过账号密码访问Nginx
nginx_http_ssl_module	            ssl模块,用于加密的http连接,如https

5、nginx内置变量

http核心模块的内置变量:http请求变量、nginx内置变量、自定义变量
$uri: 当前请求的uri,不带参数
$request_uri: 请求的uri,带完整参数
$host: http请求报文中host首部,如果没有则以处理此请求的虚拟主机的主机名代替
$hostname: nginx服务运行在主机的主机名
$remote_addr: 客户端IP
$remote_port: 客户端端口
$remote_user: 使用用户认证时客户端用户输入的用户名
$request_filename: 用户请求中的URI经过本地root或alias转换后映射的本地文件路径
$request_method: 请求方法, GET POST PUT
$server_addr: 服务器地址
$server_name: 服务器名称
$server_port: 服务器端口
$server_protocol: 服务器向客户端发送响应时的协议, 如http/1.1 http/1.0
$scheme:在请求中使用scheme, 如http://xxx.com中的http
$http_HEADER: 匹配请求报文中指定的HEADER
$http_host: 匹配请求报文中的host首部
$document_root: 当前请求映射到的root配置
© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容