安装
download nginx & pcre & LuaJIT
[root@LinuxEA local]# curl -sO http://nginx.org/download/nginx-1.10.1.tar.gz
[root@LinuxEA local]# curl -sO http://nchc.dl.sourceforge.net/project/pcre/pcre/8.39/pcre-8.39.tar.gz
[root@LinuxEA local]# curl -sO http://luajit.org/download/LuaJIT-2.0.4.tar.gz
解压
[root@LinuxEA local]# tar xf nginx-1.10.1.tar.gz
[root@LinuxEA local]# ln -s nginx-1.10.1 nginx
[root@LinuxEA local]# tar xf pcre-8.39.tar.gz
[root@LinuxEA local]# tar xf LuaJIT-2.0.4.tar.gz
编译LuaJIT
[root@LinuxEA local]# yum install gcc -y
[root@LinuxEA local]# cd LuaJIT-2.0.4
[root@LinuxEA LuaJIT-2.0.4]# make && make install
编译PCRE
[root@LinuxEA local]# yum install gcc-c++ -y
[root@LinuxEA local]# cd pcre-8.39 && ./configure
[root@LinuxEA local]# make && make install
设置环境变量
[root@LinuxEA local]# export LUAJIT_LIB=/usr/local/lib
[root@LinuxEA LuaJIT-2.0.4]# export LUAJIT_INC=/usr/local/include/luajit-2.0/
创建用户
[root@LinuxEA nginx]# useradd -s /sbin/nologin -M nginx
[root@LinuxEA LuaJIT-2.0.4]# cd ../nginx
### get ngx_devel_kit & lua-nginx-module
在编译之前,我们到此处下载相应的模块https://github.com/simpl/ngx_devel_kit#warning-using-ndk_all
[root@LinuxEA local]# yum install git
[root@LinuxEA local]# git clone https://github.com/simpl/ngx_devel_kit.git
在下载一个lua-nginx-module
[root@LinuxEA local]# git clone https://github.com/openresty/lua-nginx-module.git
开始编译nginx
--add指定目录即可
在编译之前,我们把依赖包安装
[root@LinuxEA nginx]# yum install -y openssl openssl-devel
[root@LinuxEA nginx]# ./configure --prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-file-aio \
--add-module=../ngx_devel_kit/ \
--add-module=../lua-nginx-module/ \
--with-http_gzip_static_module \
--with-http_flv_module \
--with-pcre=/usr/local/pcre-8.39 \
--with-http_mp4_module \
--http-client-body-temp-path=/var/tmp/nginx/client \
--http-proxy-temp-path=/var/tmp/nginx/proxy \
--http-fastcgi-temp-path=/var/tmp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock
[root@LinuxEA nginx]# make -j2 && make install
[root@LinuxEA nginx-1.10.1]# ln -s /usr/local/lib/libluajit-5.1.so.2 /lib64/
[root@LinuxEA nginx-1.10.1]# mkdir -p /var/tmp/nginx/{client,fastcgi,proxy,uwsgi}
我们在server中添加一个nginx lua
[root@LinuxEA conf]# vi nginx.conf
location /linuxea {
default_type 'text/plain';
content_by_lua 'ngx.say("hello,lua")';
}
[root@LinuxEA conf]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
关闭防火墙并启动
[root@LinuxEA conf]# setenforce 0
[root@LinuxEA conf]# echo -e 'net.ipv6.conf.all.disable_ipv6 = 1\nnet.ipv6.conf.default.disable_ipv6 = 1' >> /etc/sysctl.conf && sysctl -p
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
[root@LinuxEA conf]# systemctl mask firewalld
[root@LinuxEA conf]# systemctl stop firewalld
[root@LinuxEA conf]# /usr/local/nginx/sbin/nginx