---
title: "OpenResty初步使用"
author: "sichunli_030"
date: "2017-06-17T17:17:33Z"
tags: []
categories: ["开源软件"]
slug: "openresty"
draft: false
lastmod: "2017-06-17T19:45:42Z"
id: 2379956
url: "https://rd-030.iteye.com/blog/2379956"
---

<http://blog.csdn.net/yoara/article/details/52484268>


LUA require 搜索路径指定方法
如果是一个 *.LUA 的文件， 里面用到了自己写的库， 或者第三方写的库， 但是你不想把它放到 lua 的安装目录里， 则在代码里面可以指定require搜索的路径


```shell
package.path = '/usr/local/share/lua/5.1/?.lua;/home/resty/?.lua;'    --搜索lua模块
package.cpath = '/usr/local/lib/lua/5.1/?.so;'        --搜索so模块
```


如果是要在 nginx.conf 文件中引用第三方的库，则需要在 http 段中添加下面的代码

```shell
lua_package_path '/usr/local/share/lua/5.1/?.lua;/home/resty/?.lua;';
lua_package_cpath '/usr/local/lib/lua/5.1/?.so;';
```