Linux下Nginx的安装步骤

本文详细介绍如何从零开始安装配置Nginx服务器,包括所需依赖库如pcre、purge模块、zlib及openssl的下载与安装过程,并提供解决常见错误的方法。

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

一、下载pcre

官网下载:http://www.pcre.org/

# wget http://sourceforge.net/projects/pcre/files/pcre/8.35/pcre-8.35.tar.gz/download

# cd /pcre-8.35


二、下载purge模块(用于删除Nginx缓存)

# wget http://labs.frickle.com/files/ngx_cache_purge-2.1.tar.gz
# tar zxvf ngx_cache_purge-2.1.tar.gz 


三、安装zlib

# wget http://prdownloads.sourceforge.net/libpng/zlib-1.2.8.tar.gz?download

# tar zxvf zlib-1.2.8.tar.gz

# cd zlib-1.2.8

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

# make && make install


四、安装openssl

# wget http://www.openssl.org/source/openssl-1.0.1h.tar.gz

# cd openssl-1.0.1h.tar.gz 

# tar zxfv openssl-1.0.1h.tar.gz 

# cd openssl-1.0.1h

# ./config 
# ./config --prefix=/usr/local/openssl
# make && make install

五、安装gcc-c++
# yum install -y gcc-c++

六、下载最新的nginx稳定版进行安装
# wget http://nginx.org/download/nginx-1.7.2.tar.gz
# tar zxvf nginx-1.7.2.tar.gz
# ./configure --with-pcre=/data/software/pcre-8.35 --add-module=../ngx_cache_purge-2.1 --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-zlib=/usr/local/zlib --with-openssl=/data/software/openssl-1.0.1h

安装:make && make install


注:如果出现:error: 'ngx_http_file_cache_node_t' has no member named 'length'异常,可能是ngx_cache_purge-2.1.tar.gz版本太旧导致

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值