Nginx网站架构实战——17、centos6.5部署nginx+Lua环境

1、系统基础信息

 
[root@tiejiang-src1 ~]# ifconfig eth0|grep 'inet addr'|awk -F ":" '{print $2}'|awk '{print $1}'
    192.168.83.129
[root@tiejiang-src1 ~]# cat /etc/redhat-release
    CentOS release 6.5 (Final)
[root@tiejiang-src1 ~]# uname -r
    2.6.32-431.el6.x86_64

2、安装配置步骤

 
[root@tiejiang-src1 ~]# yum -y install gcc gcc-c++
[root@tiejiang-src1 ~]# yum -y install openssl openssl-devel

3、创建Nginx运行的普通用户

 
[root@tiejiang-src1 ~]# useradd -s /sbin/nologin -M www

4、下载需要的程序并安装

 
[root@tiejiang-src1 ~]# cd /usr/local/src/
[root@tiejiang-src1 src]# wget http://nginx.org/download/nginx-1.9.4.tar.gz
[root@tiejiang-src1 src]# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz
[root@tiejiang-src1 src]# wget -c http://luajit.org/download/LuaJIT-2.0.4.tar.gz
[root@tiejiang-src1 src]# wget https://github.com/simpl/ngx_devel_kit/archive/v0.2.19.tar.gz
[root@tiejiang-src1 src]# wget https://github.com/openresty/lua-nginx-module/archive/v0.9.16.tar.gz
[root@tiejiang-src1 src]# tar zxvf ngx_devel_kit-0.2.19.tar.gz
[root@tiejiang-src1 src]# tar zxvf lua-nginx-module-0.9.16.tar.gz
[root@tiejiang-src1 src]# tar zxvf pcre-8.38.tar.gz

安装LuaJIT Luajit是Lua即时编译器

 
[root@tiejiang-src1 src]# tar zxvf LuaJIT-2.0.4.tar.gz
[root@tiejiang-src1 LuaJIT-2.0.4]# cd /usr/local/src/LuaJIT-2.0.4
[root@tiejiang-src1 LuaJIT-2.0.4]# make && make install

安装nginx并加载模块

 
[root@tiejiang-src1 src]# cd nginx-1.9.4/
[root@tiejiang-src1 nginx-1.9.4]# export LUAJIT_LIB=/usr/local/lib
[root@tiejiang-src1 nginx-1.9.4]# export LUAJIT_INC=/usr/local/include/luajit-2.0/
[root@tiejiang-src1 nginx-1.9.4]# ./configure --prefix=/usr/local/nginx --user=www --group=www     --with-http_ssl_module --with-http_stub_status_module --with-file-aio --with-http_dav_module --add-module=../ngx_devel_kit-0.2.19/ --add-module=../lua-nginx-module-0.9.16/ --with-pcre=/usr/local/src/pcre-8.38/
[root@tiejiang-src1 nginx-1.9.4]# make -j2 && make install
[root@tiejiang-src1 nginx-1.9.4]# ln -s /usr/local/lib/libluajit-5.1.so.2 /lib64/libluajit-5.1.so.2

安装完毕后,下面可以测试安装了,修改nginx.conf 增加第一个配置

 
[root@tiejiang-src1 nginx-1.9.4]# cd /usr/local/nginx/conf/
[root@tiejiang-src1 conf]# cp nginx.conf nginx.conf.bak
[root@tiejiang-src1 conf]# vim nginx.conf
        server {
            listen       80;
            server_name  localhost;
    
            #charset koi8-r;
    
            #access_log  logs/host.access.log  main;
    
             location /hello {
                    default_type 'text/plain';
                    content_by_lua 'ngx.say("hello,lua")';
            }
            
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
            root   html;
        }
    }
[root@tiejiang-src1 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@tiejiang-src1 conf]# /usr/local/nginx/sbin/nginx

5、测试看lua环境是否正常Nginx网站架构实战——17、centos6.5部署nginx+Lua环境

原创文章,作者:kepupublish,如若转载,请注明出处:https://blog.ytso.com/54152.html

(0)
上一篇 2021年8月7日
下一篇 2021年8月7日

相关推荐

发表回复

登录后才能评论