yum -y install pcre-devel gcc pcre-devel openssl openssl-devel
cd /tmp
wget http://tengine.taobao.org/download/tengine-2.1.0.tar.gz
tar zxvf tengine-2.1.0.tar.gz -C /opt/
安装ngx_devel_kit,lua_nginx_module,echo-nginx-module模块
yum -y install git
cd /usr/local
git clone https://github.com/simpl/ngx_devel_kit.git
git clone https://github.com/chaoslawful/lua-nginx-module.git
git clone https://github.com/agentzh/echo-nginx-module
重新编译nginx,添加模块
cd /opt/tengine-2.1.0
./configure --user=nginx --prefix=/usr/local/nginx --with-ld-opt="-Wl,-rpath,$LUAJIT_LIB" --add-module=/usr/local/ngx_devel_kit --add-module=/usr/local/echo-nginx-module --add-module=/usr/local/lua-nginx-module
make -j2
make install
echo "export PATH=/usr/local/nginx/sbin:$PATH" >>/etc/profile
source /etc/profile
echo $PATH
nginx -V
vim /usr/lib/systemd/system/nginx.service
[Unit]
Description=Tengine Server
After=network.target remote-fs.target nss-lookup.target
[Service]
Environment="CONFFILE=/usr/local/nginx/conf/nginx.conf"
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx -c $CONFFILE
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop
[Install]
WantedBy=multi-user.target
systemctl enable nginx.service
systemctl start nginx.service
systemctl status nginx.service
ps aux |grep nginx
netstat -lnp |grep 80
nginx -V
tenginx调用lua测试配置文件:
vim /usr/local/nginx/conf/nginx.conf
worker_processes auto;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
access_log /data/logs/access_kjh.log main;
location /echo {
default_type 'text/plain';
echo 'hello echo';
}
location /lua {
default_type 'text/plain';
content_by_lua 'ngx.say("hello, lua")';
}
}
}
测试访问:
本地:
curl
curl
浏览器访问:
23.x.x.3/lua