nginx编译安装思路:
1.依赖关系:基本安装依赖关系为pcre pcre-devel openssl openssl-devel gcc gcc-c++ .事先可以rpm -qa 本地检测依赖包。
2.创建安装目录,指定安装目录,可以对nginx创建软连接
3进入目录中 下载nginx官方源码版本 wget -c http://nginx.org/download/nginx-1.6.3.tar.gz 保存到本地。
4.解压源码包:tar -xf nginx-1.6.3.tar.gz 并进入目录
5. 创建nginx所属主所属组 useradd -s nginx /bin/nologin/ -M 设置为禁止登陆用户
6.编译:./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module 常用到的几个模块
可以 ./configure --help 进行查看支持的模块进行编译安装
7. make && make install 安装。
8.创建软连接: ln -s /usr/local/nginx/sbin/nginx /bin/nginx 方便使用。
9.输入 nginx 即可启动 。 本地访问ip即可。
10.netstat -anput |grep nginx 查看监听端口。
############一般安装时所产生的几个问题###################
1.依赖关系;安装前首先解决依赖关系。
2.启动时报错:查看本地80端口是否被占用
3.安装完成无法访问: 检查selinux 以及iptables or firewalld
#############企业场景常用nginx Http模块说明############
http_core_module: 包括一些核心的http参数
http_access_module:访问控制模块,用来控制网站用户对nginx的访问。
http_gzip_module:压缩模块,对nginx 的返回值进行压缩,属于性能调优模块。
http_fastcgi_module:FastCgi 模块,和动态相关的模块,例如php
http_proxy_module: 代理模块
http_upstream_module: 负载均衡模块,以及健康检查
http_rewrite_module: rewirte 地址重写模块
http_limit_conn_module: 限制用户并发数连接请求
http_limit_req_module : 定义key限制nginx请求速率。
http_log_module :访问日志模块。
http_auth_basic_module: web用户认证模块
http_ssl_module :加密的http连接 :https
http_stub_status_module : nginx 基本状态模块