centos7 安装 nginx + lua

原创 Jeff Tang  2018-03-28 11:45  阅读 501 次 次

# 安装依赖,创建目录

yum install -y wget gcc pcre-devel openssl-devel zlib-devel
mkdir -p /data/{nginx/tmp,luajit/tmp,ngx_devel_kit/tmp,lua-nginx-module/tmp}

# 安装 LuaJIT-2.0.5

wget -P /data/luajit/tmp http://luajit.org/download/LuaJIT-2.0.5.tar.gz
tar -xf /data/luajit/tmp/LuaJIT-2.0.5.tar.gz -C /data/luajit/tmp/
cd /data/luajit/tmp/LuaJIT-2.0.5
make PREFIX=/data/luajit/LuaJIT-2.0.5
make install PREFIX=/data/luajit/LuaJIT-2.0.5

# 安装 ngx_devel_kit-0.3.0

wget -P /data/ngx_devel_kit/tmp https://github.com/simpl/ngx_devel_kit/archive/v0.3.0.tar.gz
tar -xf /data/ngx_devel_kit/tmp/v0.3.0.tar.gz -C /data/ngx_devel_kit/tmp/
cp -r /data/ngx_devel_kit/tmp/ngx_devel_kit-0.3.0/ /data/ngx_devel_kit/ngx_devel_kit-0.3.0/

# 安装 lua-nginx-module-0.10.11

wget -P /data/lua-nginx-module/tmp https://github.com/openresty/lua-nginx-module/archive/v0.10.11.tar.gz
tar -xf /data/lua-nginx-module/tmp/v0.10.11.tar.gz -C /data/lua-nginx-module/tmp/
cp -r /data/lua-nginx-module/tmp/lua-nginx-module-0.10.11/ /data/lua-nginx-module/lua-nginx-module-0.10.11/

# 安装 nginx-1.12.2

wget -P /data/nginx/tmp http://nginx.org/download/nginx-1.12.2.tar.gz
tar -xf /data/nginx/tmp/nginx-1.12.2.tar.gz -C /data/nginx/tmp/ cd /data/nginx/tmp/nginx-1.12.2
export LUAJIT_LIB=/data/luajit/LuaJIT-2.0.5/lib/ export LUAJIT_INC=/data/luajit/LuaJIT-2.0.5/include/luajit-2.0/
./configure \
--prefix=/data/nginx/nginx-1.12.2 \
--user=nobody \
--group=nobody\
--with-http_gzip_static_module \
--with-poll_module \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_stub_status_module \
--with-ld-opt="-Wl,-rpath,$LUAJIT_LIB" \
--add-module=/data/ngx_devel_kit/ngx_devel_kit-0.3.0 \
--add-module=/data/lua-nginx-module/lua-nginx-module-0.10.11
make
make install
echo 'export PATH=/data/nginx/nginx-1.12.2/sbin:$PATH' >>/etc/profile
source /etc/profile
cat << EOF > /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
ExecStart=/data/nginx/nginx-1.12.2/sbin/nginx
ExecReload=/data/nginx/nginx-1.12.2/sbin/nginx -s reload
ExecStop=/data/nginx/nginx-1.12.2/sbin/nginx -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
systemctl start nginx.service
systemctl enable nginx.service

 

本文地址:https://www.easylinux.cn/archives/37
版权声明:本文为原创文章,版权归 Jeff Tang 所有,欢迎分享本文,转载请保留出处!
PREVIOUS:已经是最后一篇了

发表评论


表情