# NGINX 引用 lua 时开启调试

**URL:** <https://www.shiqidu.com/t/topic/762>\
**Category:** 开发调优\
**Tags:** NGINX\
**Created:** [2021 年11 月 26 日 08:38 UTC](https://www.shiqidu.com/t/topic/762 "2021-11-26T08:38:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

作者： ![Leon](https://www.shiqidu.com/user_avatar/www.shiqidu.com/leon/32/5_2.png) [@Leon](https://www.shiqidu.com/u/Leon)\
发布日期： [2021 年11 月 26 日 08:38 UTC](https://www.shiqidu.com/t/topic/762/1 "2021-11-26T08:38:23Z")

</div>

在nginx中使用lua，编写lua脚本时，如果lua代码报错了，也不知道是哪里错的，因为没有报错信息，只是显示 `500 Internal Server Error`，调试都没法调试，想看到lua的报错信息很简单，只需要修改一下nginx error\_log 的级别。

```bash
vim /usr/local/nginx/conf/nginx.conf

```

找到这一行

```bash
error_log /home/wwwlogs/nginx_error.log crit;

```

修改成下面这样

```bash
error_log /home/wwwlogs/nginx_error.log debug;

```

其实就是把级别 `crit` 改成 `debug`，这样就能在nginx\_error.log里看到lua的报错信息了，方便我们调试。
