其他分享
首页 > 其他分享> > 115私人定制你懂的

115私人定制你懂的

作者:互联网

115私人定制你懂的

永久客服【芯:5828つ0650】█
永久客服【芯:4058つ3626】█

一、前期准备

  1. 安装OpenResty。官网有详细的下载、安装文档

  2. 安装IDEA。同时以下安装插件
    • Lua
    • nginx Support
    • OpenResty Lua Support

二、创建并配置项目

      1. 创建一个名为luademo1的Lua项目


      2. 创建confsrc目录,并添加nginx.confbuild.xmlhelloworld.lua文件

        • nginx.conf文件

          worker_processes  1;
          error_log  logs/error.log  info;
          events {
              worker_connections  1024;
          }
          http {
              default_type  application/octet-stream;
              access_log  logs/access.log;
              lua_package_path 'luademo1/?.lua;;';
              server {
                  listen       8080;
                  server_name  localhost;
                  default_type text/html;
                  location = /favicon.ico {
                      log_not_found off;
                      access_log off;
                  }
          
                  location /test {
                      content_by_lua_file luademo1/helloworld.lua;
                  }
              }
          }
          
        • helloworld.lua文件

          local hello = function ()
              ngx.say("Hello world,Lua!")
          end
          
          hello()
        • build.xml文件

          <?xml version="1.0" encoding="UTF-8"?>
          
          <project name="luademo1" default="dist" basedir=".">
              <description>
                  run pic-server
              </description>
              <!-- set global properties for this build -->
              <property name="openresty-home" location="D:\openresty-1.15.8.2-win64"/>
              <property name="conf" location="${basedir}/conf"/>
              <property name="src" location="${basedir}/src"/>
              <property name="target-conf" location="${openresty-home}/conf"/>
              <property name="target-src" location="${openresty-home}/${ant.project.name}"/>
          
              <echo>######开发版本的ant配置#####</echo>
              <target name="clean" depends="">
                  <echo>清理openresty目录${dist}下的conf,logs,janus,januslib</echo>
                  <delete dir="${target-conf}"/>
                  <delete dir="${target-src}"/>
                  <delete>
                      <fileset dir="${openresty-home}/logs" includes="*.log">
                      </fileset>
                  </delete>
              </target>
          
              <target name="init" depends="clean">
                  <echo>创建安装目录</echo>
                  <mkdir dir="${target-conf}"/>
                  <mkdir dir="${target-src}"/>
              </target>
          
              <target name="dist" depends="init" description="generate the distribution" >
                  <echo>复制安装文件</echo>
                  <copy todir="${target-conf}">
                      <fileset dir="${conf}"></fileset>
                  </copy>
                  <copy todir="${target-src}">
                      <fileset dir="${src}"></fileset>
                  </copy>
              </target>
          
          </project>

          其中build.xml文件中的D:\openresty-1.15.8.2-win64一定要换成OpenResty的真实安装目录

      3. 配置nginx server,用于在IDEA中启动nginx





      4. 配置Ant Build,用于将confsrc中的文件拷贝到OpenResty安装目录下的指定路径
        • 右键build.xml文件,选中Add as Ant Build File

        • 点击Ant中的Run执行一下

        Ant依赖JDK环境,因此在项目中指定一下JDK版本,这里选址JDK1.8

        再次运行Ant,在OpenResty安装目录下看到文件已经拷贝过来了

        • 设置启动Nginx Server前先运行Ant执行文件拷贝


      5. 配置nginx.conf高亮,File->Settings->Editor->File Types,选中Nginx Config后添加nginx*.conf

        配置前:

标签:Ant,log,lua,115,nginx,conf,定制,私人,OpenResty
来源: https://www.cnblogs.com/115vip/p/12434235.html