Nginx1.10.1lua环境编译安装


install

I. 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

II. 解压

[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

III. 编译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

IV. 编译PCRE

[root@LinuxEA local]# yum install gcc-c++ -y
[root@LinuxEA local]# cd pcre-8.39 && ./configure
[root@LinuxEA local]# make && make install

V. 设置环境变量

[root@LinuxEA local]# export LUAJIT_LIB=/usr/local/lib
[root@LinuxEA LuaJIT-2.0.4]# export LUAJIT_INC=/usr/local/include/luajit-2.0/

VI. 创建用户

[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

VII. 开始编译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

VIII. 关闭防火墙并启动

[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

0 分享

您可以选择一种方式赞助本站

支付宝扫码赞助

支付宝扫码赞助

日期: 2016-09-15分类: Nginx

标签: nginx

发表评论