您的位置:首页 > 运维架构 > Nginx

安装nginx

2015-12-02 11:49 453 查看

1. 安装依赖包

nginx依赖以下模块:

gzip模块需要 zlib 库

rewrite模块需要 pcre 库

ssl 功能需要openssl库

安装依赖包前,编译环境gcc,g++之类的需提前装好,如果没有通过以下命令安装:

安装make:

yum -y install gcc automake autoconf libtool make


安装g++:

yum install gcc gcc-c++


安装zlib

下载zlib安装包,解压到/usr/local/目录(也可以解压到其他目录,这个目录后面编译nginx的时候要用到)

tar -zxvf zlib-1.2.8.tar.gz
mv zlib-1.2.8 /usr/local/
cd /usr/local/zlib-1.2.8
./configure
make
make install


安装pcre

下载pcre安装包,解压到/usr/local/目录

tar -zxvf pcre-8.32.tar.gz
mv pcre-8.32 /usr/local/
cd /usr/local/pcre-8.32
./configure
make
make install


openssl

下载openssl安装包,解压到/usr/local/目录

wget http://www.openssl.org/source/openssl-1.0.1e.tar.gz tar -zxvf openssl-1.0.1e.tar.gz
mv openssl-1.0.1e /usr/local/


2. 安装nginx

tar -zxvf nginx-1.8.0.tar.gz
cd nginx-1.8.0
./configure --with-http_ssl_module --with-pcre=/usr/local/pcre-8.32 --with-zlib=/usr/local/zlib-1.2.8 --with-openssl=/usr/local/openssl-1.0.1e
make
make install


其中:

–with-pcre=/usr/local/pcre-8.32,指的是pcre的源码路径。

–with-zlib=/usr/local/zlib-1.2.8,指的是zlib的源码路径。

–with-openssl=/usr/local/openssl-1.0.1e,指的是openssl的源码路径。

默认情况下,nginx将安装在/usr/local/nginx目录。

启动nginx:

cd /usr/local/nginx/sbin
./nginx
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  nginx