centos编译nginx

以下是自用的nginx编译归纳

yum安装常用包

yum -y update
yum -y install epel-release -y
yum install lua-devel luajit git -y
yum -y --skip-broken install gcc  vim-enhanced gcc-c++ libtool-libs libtool autoconf subversion zip unzip  wget crontabs iptables file bison patch mlocate flex diffutils automake imake make cmake kernel-devel cpp zlib-devel

编译安装pcre

cd /tmp
wget -c http://sourceforge.net/projects/pcre/files/pcre/8.21/pcre-8.21.tar.gz/download -O -|tar xz
cd pcre-8.21
./configure
make && make install
if [ `uname -i` == x86_64 ]; then ln -s /usr/lib64/{libpcre.*,libjpeg.so,libpng.so,libXpm.so,libc-client.so,libkrb5.so,libexpat.so,libevent.so} /usr/lib/;fi

编译安装sregex

replace-filter-nginx-module需要sregex ,如不需要可以略过。

cd /tmp
git clone https://github.com/agentzh/sregex
cd sregex
make && make install
if [ `uname -m` == "x86_64" ]; then archlib="lib64"; else archlib="lib"; fi
ln -s /usr/local/lib/libsrege* /usr/$archlib/

开始编译nginx

1.如果没有编译安装sregex, 请移除--add-module=replace-filter-nginx-module
 2. libressl和openssl选择之间需要改变 --with-openssl=的目录

nginxV=1.13.6;  #自定义版本  
cd /tmp;
wget -c  http://nginx.org/download/nginx-$nginxV.tar.gz -O -|tar xz; cd nginx-$nginxV
#wget -c http://www.openssl.org/source/openssl-1.0.1o.tar.gz -O -|tar xz && mv openssl-* openssl
wget -c https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-2.6.2.tar.gz -O -|tar xz && mv libressl-* libressl
git clone https://github.com/agentzh/memc-nginx-module
git clone https://github.com/agentzh/srcache-nginx-module
git clone https://github.com/agentzh/echo-nginx-module
git clone https://github.com/agentzh/replace-filter-nginx-module
git clone https://github.com/yaoweibin/ngx_http_substitutions_filter_module
#git clone https://github.com/pagespeed/ngx_pagespeed
git clone https://github.com/chaoslawful/lua-nginx-module
git clone https://github.com/simpl/ngx_devel_kit
git clone https://github.com/openresty/set-misc-nginx-module
./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --pid-path=/var/run/nginx.pid  --conf-path=/etc/nginx/nginx.conf --lock-path=/var/lock/subsys/nginx --with-stream=dynamic   --with-stream_ssl_module   --with-stream_realip_module --with-stream_ssl_preread_module  --with-mail=dynamic --with-mail_ssl_module --with-openssl=libressl --with-http_v2_module --with-pcre --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module  --with-http_secure_link_module --with-http_dav_module  --with-http_ssl_module --add-module=ngx_http_substitutions_filter_module  --add-module=replace-filter-nginx-module --add-module=echo-nginx-module --add-module=lua-nginx-module  --add-module=ngx_devel_kit --add-module=set-misc-nginx-module  --with-ld-opt=-m64  --with-ld-opt="-lrt"
make -j8 && make install
sed -i 'i\fastcgi_index index.php default.php;\nfastcgi_param  SCRIPT_FILENAME  \$document_root\$fastcgi_script_name;' /etc/nginx/fastcgi_params
sed -i 's/\/\$nginx_version//g' /etc/nginx/fastcgi_params
mkdir -p /etc/nginx/conf
wget http://dl.kvm.la/conf/nginx.init.d -O /etc/init.d/nginx
wget http://dl.kvm.la/conf/nginx.conf -O /etc/nginx/nginx.conf
chmod 755 /etc/init.d/nginx
chkconfig --add nginx
chkconfig --level 235 nginx on

memc-nginx-module  srcache-nginx-module  echo-nginx-module replace-filter-nginx-module ngx_http_substitutions_filter_module 这些模块普通情况很少用,可以自行去掉。

lua的用途很广需

添加新评论 »