Nginx 编译安装

1. 编译安装nginx

1.1 安装PCRE(Perl Compatible Regular Expressions),中文perl兼容正则表达式.
bash-4.3 ~# yum -y install pcre pcre-devel
bash-4.3 ~# rpm -qa | grep pcre*
pcre-7.8-7.el6.x86_64
pcre-devel-7.8-7.el6.x86_64
1.2 安装openssl
bash-4.3 ~# yum -y install openssl-devel
1.3 安装Nginx
bash-4.3 ~# cd /usr/local/src
bash-4.3 src# tar xf nginx-1.10.1.tar.gz
bash-4.3 src# cd nginx-1.10.1
bash-4.3 nginx-1.10.1# useradd -M -s /sbin/nologin nginx
bash-4.3 nginx-1.10.1# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module
### --user、--group: 用户和组
### --with-http_ssl_module: 加载ssl
### --with-http_stub_status_module: nginx监控
bash-4.3 nginx-1.10.1# echo $?
0
bash-4.3 nginx-1.10.1# make
bash-4.3 nginx-1.10.1# make install
bash-4.3 nginx-1.10.1# echo $?
0
bash-4.3 nginx-1.10.1# /usr/local/nginx/sbin/nginx -V   #查看Nginx配置参数
nginx version: nginx/1.10.1
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC) 
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module
1.4 Nginx目录介绍
bash-4.3 nginx-1.10.1#  cd /usr/local/nginx
bash-4.3 nginx# ll |awk 'NR>3 {print $NF}'
conf            #配置文件目录
html            #默认网站目录
logs            #日志目录
sbin            #Nginx启动命令
bash-4.3 nginx# /usr/local/nginx/sbin/nginx     #启动Nginx
bash-4.3 nginx# lsof -i:80                      #查看80端口
COMMAND  PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
nginx   7669  root    6u  IPv4  25184      0t0  TCP *:http (LISTEN)
nginx   7670 nginx    6u  IPv4  25184      0t0  TCP *:http (LISTEN)
### 浏览器访问服务器ip

请输入图片描述

1.5 更改默认主页(index.html)信息
bash-4.3 nginx# cd html
bash-4.3 html# echo "<a href="http://www.90root.com">www.90root.com</a>" > index.html 
### 浏览器访问服务器ip

请输入图片描述

1.6 企业场景常用的Nginx http功能模块
ngx_http_core_module: 包括一些核心的http参数配置,对应Nginx的配置为http区块部分.
ngx_http_access_module: 访问控制模块,用来控制网站用户对Nginx的访问.
ngx_http_gzip_module: 压缩模块, 对Nginx返回的数据压缩,属于性能优化模块.
ngx_http_fastcgi_module: fastcgi模块和动态应用相关的模块.如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
ngx_http_ssl_module: ssl模块,用于加密的http连接.如https
ngx_http_stub_status_module: 记录Nginx基本访问状态信息等模块


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章