nginx源码安装

本文档详细介绍了如何手动编译安装nginx,包括安装依赖库如pcre、openssl和zlib,创建目录,解压文件,以及配置和编译安装过程。特别提示,在安装时需要注意某些选项的使用,例如避免使用--with-pcre选项,以防止编译错误。

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


nginx源码安装
 
       安装环境:
 
                     操作系统:Ubuntu 12.04
 
                     Nginx:     V1.4.2
 
                     PCRE:    V8.33
 
                     zlib:         V1.2.8
 
        下载上述源包到当前用户主目录(本机:/home/tdtc100)。
 
       1. 安装zlib
 
           (1)解压缩
 
[plain] 
tdtc100@ubuntu:~$ tar zxvf zlib-1.2.8.tar.gz  
           (2)安装
 
[plain] 
tdtc100@ubuntu:~$ cd zlib-1.2.8  
tdtc100@ubuntu:~/zlib-1.2.8$ ./configure  
tdtc100@ubuntu:~/zlib-1.2.8$ make  
tdtc100@ubuntu:~/zlib-1.2.8$ sudo make install  
       2. 安装PCRE
 
           (1) 安装依赖包
 
             c++
 
[plain] 
sudo apt-get install build-essential  
            注:如果不安装,在进行(3)时,会出现:
 
[plain] 
configure: error: You need a C++ compiler for C++ support.  
          (2)解压缩
 
[plain] 
tdtc100@ubuntu:~$ tar zxvf pcre-8.33.tar.gz  
           (3)安装
 
[plain] 
tdtc100@ubuntu:~$ cd pcre-8.33  
tdtc100@ubuntu:~/pcre-8.33$ ./configure  
tdtc100@ubuntu:~/pcre-8.33$ make  
tdtc100@ubuntu:~/pcre-8.33$ sudo make install  
        3. 安装nginx
 
          (1)安装依赖包
 
            open-ssl library
 
[plain] 
sudo apt-get install libcurl4-openssl-dev  
            注:如果不安装,在进行(3)时,会出现:
 
[plain] 
./configure: error: SSL modules require the OpenSSL library.  
You can either do not enable the modules, or install the OpenSSL library  
into the system, or build the OpenSSL library statically from the source  
with nginx by using --with-openssl=<path> option.  
          (2)解压缩
 
[plain] 
tdtc100@ubuntu:~$ tar zxvf nginx-1.4.2.tar.gz  
          (3)安装
                   参考官方文档
[plain] 
tdtc100@ubuntu:~$ cd nginx-1.4.2  
tdtc100@ubuntu:~/nginx-1.4.2$ ./configure \  
> --sbin-path=/usr/local/nginx/nginx \  
> --conf-path=/usr/local/nginx/nginx.conf \  
> --pid-path=/usr/local/nginx/nginx.pid \  
> --with-http_ssl_module \  
> --with-pcre=../pcre-8.33 \  
> --with-zlib=../zlib-1.1.3  
tdtc100@ubuntu:~/nginx-1.4.2$ make  
tdtc100@ubuntu:~/nginx-1.4.2$ sudo make install  
 
 
-------------------------安装完毕-----------------------xiaobin_hlj80-------------------------------------------
 
 
 
运行:
 
[plain] 
tdtc100@ubuntu:/usr/local/nginx$ sudo ./nginx  
 
运行效果:
 

wbq安装按照下方:
安装nginx-1.4.3.tar.gz的过程完整记录下来,以免后面每次找得麻烦。


安装过程中的文件:

nginx-1.4.3.tar.gz

pcre-8.21.tar.gz

openssl-1.0.1c.tar.gz

zlib-1.2.8.tar.gz

包文件会上传到资源里面


安装开始:

1、先配置好yum,完全安装make,gcc-c++,各个devel

yum -y installgcc automake autoconf libtool make

yum install -y gcc gcc-c++


yum install pcre-devel.x86-64

yum install zlib-devel.x86-64

yum install openssl-devel.x86-64


2、创建好目录

mkdir /usr/local/pcre

mkdir /usr/local/openssl

mkdir /usr/local/zlib

mkdir /usr/local/nginx


3、上传文件到指定目录并解压,以/opt/nginx为例

tar -zxvf nginx-1.4.3.tar.gz


4、安装pcre

cd /opt/nginx/pcre-8.21

./configure --prefix=/usr/local/pcre

make && make install


5、安装openssl

cd /opt/nginx/openssl-1.0.1c

./config --prefix=/usr/local/openssl

make && make install


6、安装zlib

cd /opt/nginx/zlib-1.2.8

./configure --prefix=/usr/local/zlib

make && make install


7、安装nginx

./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --without-http_rewrite_module --with-http_flv_module --with-zlib=/opt/nginx/zlib-1.2.8 --with-openssl=/opt/nginx/openssl-1.0.1c

make

make install


到此nginx安装完成。


此过程中注意项:

要确保安装好make

另外面在实际安装过程中,不用带pcre的选项(如 --with-pcre=/opt/nginx/pcre-8.21)

出现上述的情况时,make会出现如下错误:

objs/src/core/nginx.o: In function `main':
/tmp/newLNMP/lanmp/nginx-1.2.6/src/core/nginx.c:275: undefined reference to `ngx_regex_init'


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值