boss44 发表于 2018-11-11 06:46:17

tengine(nginx)安装,lua模块安装

  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
  
  Description=Tengine Server
  After=network.target remote-fs.target nss-lookup.target
  
  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>  ExecStop=/usr/local/nginx/sbin/nginx -s stop
  
  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_processesauto;
  events {
  worker_connections1024;
  }
  http {
  include       mime.types;
  default_typeapplication/octet-stream;
  log_formatmain'$remote_addr - $remote_user [$time_local] "$request" '
  '$status $body_bytes_sent "$http_referer" '
  '"$http_user_agent" "$http_x_forwarded_for"';
  #access_loglogs/access.logmain;
  sendfile      on;
  #tcp_nopush   on;
  #keepalive_timeout0;
  keepalive_timeout65;
  #gzipon;
  server {
  listen       80;
  server_namelocalhost;
  access_log/data/logs/access_kjh.logmain;
  location /echo {
  default_type 'text/plain';
  echo 'hello echo';
  }
  location /lua {
  default_type 'text/plain';
  content_by_lua 'ngx.say("hello, lua")';
  }
  }
  }
  测试访问:
  本地:
  curl http://127.0.0.1/lua
  curl http://127.0.0.1/echo
  浏览器访问:
  23.x.x.3/lua

页: [1]
查看完整版本: tengine(nginx)安装,lua模块安装