nginx 源码安装编译

ubuntu 16.04

1.

PCRE – Supports regular expressions. Required by the NGINX Core and Rewrite modules.

$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.42.tar.gz
$ tar -zxf pcre-8.42.tar.gz
$ cd pcre-8.42
$ ./configure
$ make
$ sudo make install

 

2.

zlib – Supports header compression. Required by the NGINX Gzip module.

$ wget http://zlib.net/zlib-1.2.11.tar.gz
$ tar -zxf zlib-1.2.11.tar.gz
$ cd zlib-1.2.11
$ ./configure
$ make
$ sudo make install

 

3.

OpenSSL – Supports the HTTPS protocol. Required by the NGINX SSL module and others.

$ wget http://www.openssl.org/source/openssl-1.0.2o.tar.gz
$ tar -zxf openssl-1.0.2o.tar.gz
$ cd openssl-1.0.2o
$ ./Configure darwin64-x86_64-cc --prefix=/usr
$ make
$ sudo make install

 

nginx 编译

./configure --prefix=/usr/share/nginx  \
           --conf-path=/etc/nginx/nginx.conf \
           --modules-path=/usr/lib/nginx/modules \
           --error-log-path=/var/log/nginx/error.log \
           --http-log-path=/var/log/nginx/access.log \
           --pid-path=/opt/run/nginx --user=websuite \
           --group=websuite \
           --with-file-aio \
           --with-http_ssl_module \
           --with-http_v2_module \
           --with-http_stub_status_module \
           --without-http_ssi_module \
           --without-http_charset_module \
           --without-http_access_module \
           --without-http_auth_basic_module \
           --without-http_autoindex_module \
           --without-http_geo_module \
           --without-http_split_clients_module \
           --without-http_proxy_module \
           --without-http_fastcgi_module \
           --without-http_uwsgi_module \
           --without-http_scgi_module \
           --without-http_memcached_module \
           --without-http_empty_gif_module \
           --without-http_browser_module \
           --without-http_upstream_hash_module \
           --without-http_upstream_ip_hash_module \
           --without-http_upstream_least_conn_module \
           --without-http_upstream_keepalive_module \
           --without-http_upstream_zone_module \
           --http-client-body-temp-path=/opt/websuite/nginx/temp/client \
           --without-mail_pop3_module \
           --without-mail_imap_module \
           --without-mail_smtp_module \
           --with-google_perftools_module \
           --with-pcre=../pcre-8.42 \
           --with-pcre-jit \
           --with-openssl=../openssl-1.0.2o \
           --with-openssl-opt="threads shared no-zlib no-comp no-ssl2 no-ssl3 no-ssl3-method"

 

安装 google_perftools_module

  git clone https://github.com/gperftools/gperftools

apt-get install autoconf automake libtool

 

[root@localhost gperftools-master]# sh autogen.sh 

./configure

make 

 

 

在makefile文件里的CFLAGS里加上 -fPIC选项,这样可以一劳永逸

 openssl-1.0.2o

pcre-8.40 

zlib-1.2.11

Makefile  CFLAGS加上  -fPIC

 

https://www.vultr.com/docs/how-to-compile-nginx-from-source-on-ubuntu-16-04

./configure --prefix=/usr/share/nginx \
            --sbin-path=/usr/sbin/nginx \
            --modules-path=/usr/lib/nginx/modules \
            --conf-path=/etc/nginx/nginx.conf \
            --error-log-path=/var/log/nginx/error.log \
            --http-log-path=/var/log/nginx/access.log \
            --pid-path=/run/nginx.pid \
            --lock-path=/var/lock/nginx.lock \
            --user=www-data \
            --group=www-data \
            --build=Ubuntu \
            --http-client-body-temp-path=/var/lib/nginx/body \
            --http-fastcgi-temp-path=/var/lib/nginx/fastcgi \
            --http-proxy-temp-path=/var/lib/nginx/proxy \
            --http-scgi-temp-path=/var/lib/nginx/scgi \
            --http-uwsgi-temp-path=/var/lib/nginx/uwsgi \
            --with-openssl=../openssl-1.1.0f \
            --with-openssl-opt=enable-ec_nistp_64_gcc_128 \
            --with-openssl-opt=no-nextprotoneg \
            --with-openssl-opt=no-weak-ssl-ciphers \
            --with-openssl-opt=no-ssl3 \
            --with-pcre=../pcre-8.40 \
            --with-pcre-jit \
            --with-zlib=../zlib-1.2.11 \
            --with-compat \
            --with-file-aio \
            --with-threads \
            --with-http_addition_module \
            --with-http_auth_request_module \
            --with-http_dav_module \
            --with-http_flv_module \
            --with-http_gunzip_module \
            --with-http_gzip_static_module \
            --with-http_mp4_module \
            --with-http_random_index_module \
            --with-http_realip_module \
            --with-http_slice_module \
            --with-http_ssl_module \
            --with-http_sub_module \
            --with-http_stub_status_module \
            --with-http_v2_module \
            --with-http_secure_link_module \
            --with-mail \
            --with-mail_ssl_module \
            --with-stream \
            --with-stream_realip_module \
            --with-stream_ssl_module \
            --with-stream_ssl_preread_module \
            --with-debug \
            --with-cc-opt='-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2' \
            --with-ld-opt='-Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now'
make 
sudo make install

 

 

 

https://www.vultr.com/docs/how-to-compile-nginx-from-source-on-ubuntu-16-04

你可能感兴趣的:(nginx 源码安装编译)