将压缩文件都拷贝到/usr/local目录下面:
1、安装zlib-1.2.11.tar.gz
解压:tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make
make install
2、安装pcre-8.40.tar.gz
解压:tar –zxvf pcre-8.40.tar.gz
cd pcre-8.40
./configure
make
make install
3、安装openssl-1.0.1s.tar.gz
tar -zxf openssl-1.0.1s.tar.gz
cd openssl-1.0.1s
./config
make
make test
make install
4、安装 nginx-1.11.13.tar.gz
cd nginx-1.11.13
./configure --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --pid-path=/usr/local/nginx/sbin/nginx.pid --with-http_ssl_module --with-pcre=../pcre-8.40 --with-zlib=../zlib-1.2.11
或者
./configure --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf--pid-path=/usr/local/nginx/sbin/nginx.pid --with-http_ssl_module --with-stream--with-pcre=../pcre-8.40 --with-zlib=../zlib-1.2.11 --with-openssl=/usr/local/ssl
make
测试 nginx.conf 的配置是否正确: /usr/local/nginx/sbin/nginx -t
根据nginx.conf里的配置,启动nginx服务 : /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
出现错误:
错误1:checking for OS
+ Linux 2.6.32-431.el6.x86_64 x86_64
checking for Ccompiler ... not found
./configure:error: C compiler cc is not found
执行脚本:yum install gcc-c++
yum cleanall
yum makecache
错误2:./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSLlibrary
into the system, or build the OpenSSL library statically from thesource
with nginx by using --with-openssl=<path> option.
获取路径which openssl
添加--with-openssl=/usr/bin/openssl
错误3: [/usr/local/openssl//.openssl/include/openssl/ssl.h]Error 127解决方案:
打开nginx源文件下的/usr/local/src/nginx-1.11.13/auto/lib/openssl/conf文件:
找到这么一段代码:
CORE_INCS="$CORE_INCS $OPENSSL/.openssl/include"
CORE_DEPS="$CORE_DEPS $OPENSSL/.openssl/include/openssl/ssl.h"
CORE_LIBS="$CORE_LIBS $OPENSSL/.openssl/lib/libssl.a"
CORE_LIBS="$CORE_LIBS $OPENSSL/.openssl/lib/libcrypto.a"
CORE_LIBS="$CORE_LIBS $NGX_LIBDL"
修改成以下代码:
CORE_INCS="$CORE_INCS $OPENSSL/include"
CORE_DEPS="$CORE_DEPS $OPENSSL/include/openssl/ssl.h"
CORE_LIBS="$CORE_LIBS $OPENSSL/lib/libssl.a"
CORE_LIBS="$CORE_LIBS $OPENSSL/lib/libcrypto.a"
CORE_LIBS="$CORE_LIBS $NGX_LIBDL"