安装
-
在Centos下,yum源不提供nginx的安装,可以通过切换yum源的方法获取安装。也可以通过直接下载安装包的方法,**以下命令均需root权限执行**:
-
首先安装必要的库(nginx 中gzip模块需要 zlib 库,rewrite模块需要 pcre 库,ssl 功能需要openssl库)。选定**/usr/local**为安装目录,以下具体版本号根据实际改变。
1.安装gcc gcc-c++(如新环境,未安装请先安装)
-
$ yum install -y gcc gcc-c++
-
2.安装PCRE库
-
$ cd /usr/local/
-
$ wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.33/pcre-8.33.tar.gz
-
$ tar -zxvf pcre-8.36.tar.gz
-
$ cd pcre-8.36
-
$ ./configure
-
$ make && make install
-
-
如报错:configure: error: You need a C++ compiler for C++ support
-
解决:yum install -y gcc gcc-c++
-
3.安装SSL库
-
$ cd /usr/local/
-
$ wget http://www.openssl.org/source/openssl-1.0.1j.tar.gz
-
$ tar -zxvf openssl-1.0.1j.tar.gz
-
$ cd openssl-1.0.1j
-
$ ./config
-
$ make && make install
-
-
4.安装zlib库存
$ cd /usr/local/
$ wget http://zlib.net/zlib-1.2.11.tar.gz
$ tar -zxvf zlib-1.2.11.tar.gz
$ ./configure
$ make && make install
然后就是安装nginx了
./configure
make && make install
默认配置会安装到 /usr/local/nginx 下
进入sbin目录;输入 ./nginx 就可以启动了
./nginx 开启
./nginx -s stop 停止
./nginx -s quit
./nginx -s reload
原文链接:https://www.cnblogs.com/jackyzm/p/9600738.html
以上方式在配置ssl证书时会报错,./configure出了问题,更好的安装方式如下