下載源代碼
http://nginx.org/en/download.html
tar -xvf nginx-<version>.tar.gz
./configure
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
安裝pcre
sudo apt install libpcre3 libpcre3-dev
繼續安裝nginx
./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.
安裝zlib
下載地址:http://www.zlib.net/
tar -xvf zlib-<version>.tar.gz
cd zlib-<version>/
./configure
make
make install
繼續configure nginx,編譯沒有問題了
make && make install
源碼的安裝路徑為 /usr/local/nginx/sbin/nginx 而采用apt安裝的路徑為/usr/sbin/nginx
apt安裝的版本為1.10.3 源代碼安裝的版本是1.15.10
以下為了實現平移
- 結束nginx進程
- 將/usr/sbin/nginx備份一下 并創建軟鏈接
mv /usr/sbin/nginx /usr/sbin/nginx_old
ln -s /usr/local/nginx/sbin/nginx /usr/sbin/nginx
再次啟動時:
Failed to start A high performance web server and a reverse proxy server.
重新編譯:
./configure --with-http_ssl_module
./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.
安裝ssl library
源碼:https://www.openssl.org/source/
$ ./config
$ make
$ make test
$ make install
nginx:
./configure --with-http_ssl_module --with-openssl=<ssl_src path>
make && make install
運行:
nginx: [emerg] unknown directive "stream" in /etc/nginx/nginx.conf:78
nginx重新配置
./configure --with-http_ssl_module --with-openssl=<ssl_src path> --with-stream
make && make install