原文链接:从零搭建 Nginx + Lua 开发环境 CentOS-6.7 + Nginx-1.11.2 + LuaJIT-2.1.0 + LuaRocks-2.4.2
本文主要介绍从零搭建 Nginx + Lua开发环境,系统及软件环境为 CentOS-6.7 + Nginx-1.11.2 + LuaJIT-2.1.0 + LuaRocks-2.4.2。
1.建立 soft 目录
mkdir soft
cd soft/
2.安装必备的工具
sudo yum -y install gcc automake autoconf libtool make libffi-devel python-devel openssl-devel libbz2-dev libXext libXrender fontconfig libfontconfig.so.1 libgfortran gcc-gfortran lapack-devel.x86_64 blas-devel.x86_64 gcc-c++ pcre-devel zlib-devel epel-release
3.更新系统
sudo yum update
sudo yum upgrade
4.设置中文语言
编辑 /etc/profile
文件,在文件最下面输入变量
sudo vi /etc/profile
export LC_ALL=zh_CN.utf-8
export LANG=zh_CN.utf-8
source /etc/profile
5.设置时区
sudo cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
sudo vi /etc/sysconfig/clock
#ZONE="Etc/UTC"
ZONE="Asia/Shanghai"
UTC=false
ARC=false
sudo ntpdate -u ntp.api.bz
6.安装 LuaJIT
wget http://luajit.org/download/LuaJIT-2.1.0-beta2.tar.gz
tar -zxvf LuaJIT-2.1.0-beta2.tar.gz
cd LuaJIT-2.1.0-beta2
make
sudo make install
sudo vi /etc/profile
export LUAJIT_LIB=/usr/local/lib
export LUAJIT_INC=/usr/local/include/luajit-2.1
source /etc/profile
7.安装 Nginx
7.1 下载 Nginx 开发套件 ngx_devel_kit
wget https://github.com/simpl/ngx_devel_kit/archive/v0.3.0.tar.gz
tar -zxvf v0.3.0.tar.gz
7.2 下载 Nginx 的 Lua 模块
wget https://github.com/openresty/lua-nginx-module/archive/v0.10.7.tar.gz
tar -zxvf v0.10.7.tar.gz
7.3 安装 Nginx
wget http://nginx.org/download/nginx-1.11.2.tar.gz
tar -xzvf nginx-1.11.2.tar.gz
cd nginx-1.11.2
./configure --with-ld-opt="-Wl,-rpath,/usr/local/lib" --add-module=/home/tianqi/soft/ngx_devel_kit-0.3.0 --add-module=/home/tianqi/soft/lua-nginx-module-0.10.7 --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module
sudo make && sudo make install
8.安装 LuaROCKS
cd ../soft/
wget http://luarocks.github.io/luarocks/releases/luarocks-2.4.4.tar.gz
tar -zxvf luarocks-2.4.4.tar.gz
cd luarocks-2.4.4
./configure --with-lua="/usr/local" --lua-suffix="jit-2.1.0-beta2" --with-lua-include="/usr/local/include/luajit-2.1"
make build
sudo make install
sudo mkdir /usr/local/lib/luarocks
sudo mkdir /usr/local/lib/luarocks/rocks
sudo chmod -R 777 /usr/local/lib/luarocks/rocks
sudo chmod -R 777 /usr/local/
9.安装其他组件
luarocks install luaposix
luarocks install luacrypto
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于