ubuntu 14.04LTS 系统下安装nginx


 

nginx源码安装
说明:使用nginx源码编译的方式安装时,需要先安装nginx的依赖库pcre、zlib、oppenssl。
官网下载地址
http://nginx.org/en/download.html
$ wget http://nginx.org/download/nginx-1.15.3.tar.gz
$ tar -zxvf nginx-1.15.3.tar.gz
$ cd nginx-1.15.3
$ sudo ./configure --prefix=/usr/local/nginx --with-pcre=../pcre-8.38 --with-zlib=../zlib-1.2.11 --with-openssl=../openssl-1.0.1f --with-http_ssl_module
$ sudo make && sudo make install

$ sudo ./configure --prefix=/usr/local/nginx-test22 --with-pcre=../pcre-8.38 --with-zlib=../zlib-1.2.11 --with-openssl= --with-http_ssl_module
Tips:
    --with-pcre=../pcre-8.38 //pcre-8.38为pcre的源码目录(不是安装目录)
    --with-zlib=../zlib-1.2.11 //zlib-1.2.11为zlib的源码目录(不是安装目录)
    --with-openssl=../openssl-1.0.1f
    --with-http_ssl_module
    如果安装过程出现错误,有可能是pcre的版本不兼容,
依赖库
1、pcre
官网下载地址
https://ftp.pcre.org/pub/pcre/
$ wget https://ftp.pcre.org/pub/pcre/pcre-8.00.tar.gz
$ tar -zxvf pcre-8.00.tar.gz
$ cd pcre-8.00.tar.gz
$ ./configure --prefix=/usr/local/pcre
$  make
$  make check
$ sudo make install
安装pcre错误信息
configure: error: You need a C++ compiler for C++ support
解决办法:
$ sudo apt-get install build-essential

2、zlib
官网下载地址
https://zlib.net/
$ wget https://zlib.net/zlib-1.2.11.tar.gz
$ tar -zxvf zlib-1.2.11.tar.gz
$ cd zlib-1.2.11
$ ./config --prefix=/usr/local/zlib
$ make
$ make check
$ sudo make install
$ make clean
$ make distclean

3.OpenSSL
官网下载地址
https://www.openssl.org/source/
检查openssl是否安装过
$ openssl -v
如果系统默认没有安装
$ wget https://www.openssl.org/source/old/1.0.1/openssl-1.0.1f.tar.gz
$ tar -zxvf openssl-1.0.1f.tar.gz
$ cd openssl-1.0.1f
$ sudo ./configure
$ sudo make && sudo make install

如果操作系统已默认安装过openssl,也需要下载openssl任意版本的源码包,我下载和我主机上一致的版本openssl-1.0.1f。

使用openssl生成证书
具体教程可以参考https://ningyu1.github.io/site/post/51-ssl-cert/

猜你喜欢

转载自blog.csdn.net/u011504963/article/details/82465327