nginx-1.10.3 编译安装
1、系统环境
[root@crazy-acong ~]# cat /etc/redhat-release CentOS release 6.6 (Final) [root@crazy-acong ~]# uname -a Linux crazy-acong 2.6.32-504.el6.x86_64 #1 SMP Wed Oct 15 04:27:16 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux [root@crazy-acong ~]# ifconfig eth0 | grep "inet addr" | awk -F : '{print $2}'| awk '{print $1}' 192.168.1.106
2、安装步骤
2.1 安装基础依赖包
- 安装 pcre
- 安装 openssl-devel
# pcre 安装 # 安装 pcre库是为了使 nginx 支持具备 URI 重写功能的 rewrite 模块,如果不安装 pcre 库,则 nginx 无法使用 rewrite 模块功能 [root@crazy-acong ~]# yum -y install pcre pcre-devel [root@crazy-acong ~]# rpm -qa pcre pcre-devel pcre-devel-7.8-7.el6.x86_64 pcre-7.8-7.el6.x86_64 # openssl-devel 安装 # nginx 在使用HTTPS服务的时候要用到此模块,如果不安装 openssl 相关包,安装 nginx 的过程中会报错。openssl 系统默认已经安装,只需要安装 openssl-devel 即可 [root@crazy-acong ~]# yum -y install openssl-devel [root@crazy-acong ~]# rpm -qa openssl-devel openssl openssl-1.0.1e-48.el6_8.3.x86_64 openssl-devel-1.0.1e-48.el6_8.3.x86_64
2.2 安装 nginx
# 创建软件包存放目录 [root@crazy-acong ~]# mkdir -p /data/tools [root@crazy-acong ~]# cd /data/tools/ # 下载 nginx 的稳定版本 1.10.3 [root@crazy-acong tools]# wget http://nginx.org/download/nginx-1.10.3.tar.gz # 创建 nginx 用户 [root@crazy-acong tools]# useradd nginx -s /sbin/nologin -M [root@crazy-acong tools]# tar -zxf nginx-1.10.3.tar.gz [root@crazy-acong tools]# cd nginx-1.10.3 [root@crazy-acong nginx-1.10.3]# ./configure --user=nginx --group=nginx --prefix=/data/application/nginx-1.10.3 --with-http_stub_status_module --with-http_ssl_module [root@crazy-acong nginx-1.10.3]# make [root@crazy-acong nginx-1.10.3]# make install [root@crazy-acong nginx-1.10.3]# ln -s /data/application/nginx-1.10.3/ /etc/nginx [root@crazy-acong nginx-1.10.3]# ln -s /data/application/nginx-1.10.3/sbin/nginx /usr/local/sbin/ # 使用 nginx -V 可以查看编译是的参数 [root@crazy-acong ~]# /etc/nginx/sbin/nginx -V nginx version: nginx/1.10.3 built by gcc 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC) built with OpenSSL 1.0.1e-fips 11 Feb 2013 TLS SNI support enabled configure arguments: --user=nginx --group=nginx --prefix=/data/application/nginx-1.10.3/ --with-http_stub_status_module --with-http_ssl_module # 检查配置文件语法,可以防止因配置错误导致网站重启或重新加载配置等对用户的影响 [root@crazy-acong nginx-1.10.3]# nginx -t nginx: the configuration file /data/application/nginx-1.10.3//conf/nginx.conf syntax is ok nginx: configuration file /data/application/nginx-1.10.3//conf/nginx.conf test is successful # 启动 nginx 服务 [root@crazy-acong nginx-1.10.3]# nginx # 查看是否启动成功 [root@crazy-acong nginx-1.10.3]# netstat -lnpt | grep nginx tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 10334/nginx