Linux安装Nginx手册

本文详细介绍如何在Linux环境下从源码编译安装Nginx及其所需依赖库,包括zlib、pcre和openssl,并解决安装过程中遇到的典型错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

将压缩文件都拷贝到/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  

make install 
测试 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"


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值