转载请注明原始地址 http://www.cnblogs.com/dongxiao-yang/p/4877799.html

一 :系统版本

1 cat /etc/issue:

CentOS release 6.2 (Final)

Kernel \r on an \m

2 cat /proc/version :

Linux version 2.6.32-220.el6.x86_64 (mockbuild@c6b18n3.bsys.dev.centos.org) (gcc version 4.4.6 20110731 (Red Hat 4.4.6-3) (GCC) ) #1 SMP Tue Dec 6 19:48:22 GMT 2011

二:openresty 安装

官网地址 http://openresty.org/

下载版本 ngx_openresty-1.9.3.1.tar.gz

1 安装依赖包:

yum install readline-devel pcre-devel openssl-devel gcc

2 安装openresty

(1) tar -zxvf ngx_openresty-1.9.3.1.tar.gz

(2) cd ngx_openresty-1.9.3.1

(3) 安装命令参考 https://www.nginx.com/resources/wiki/modules/lua/#lua-installation 。官方推荐的一键安装命令为

./configure --with-luajit && make && make install

这个命令会把openresty安装到默认路径 /usr/local/openresty

 安装到指定路径可以在 

./configure --prefix=/opt/openresty 指定

./configure --help 可以查看更多安装选项。

本次采用

./configure  --prefix=/opt/openresty --with-luajit && make && make install

(4)luasocket 安装

参考 http://www.cnblogs.com/dongxiao-yang/p/4878323.html

openresty作者章亦春本人是非常讨厌luascoket这个库的,在https://groups.google.com/forum/#!topic/openresty/PD6lTehlhJY

邮件里他的回复是:

这个 luasocket 必会阻塞 nginx worker 进程,让你的 nginx 服务器瞬间退化成和 Apache httpd 和 
php-fpm 一样弱 :) 绝对不要在生产环境使用它!


> 看了下这里依赖于 socket.core 模块,貌似luajit下没有这个模块,但是lua 5.1 是有的. 现在在openresty 下跑不起来. 
>

标准 Lua 5.1 解释器的官方源码发布包中绝对不会有 socket.core 这种东西 :)

> 我想问的是   luasocket 模块有什么替代么,我看 lua-resty-http 里面用了 local sock = tcp() 这个tcp 
> 的socket 这个可以替代么? 
>

ngx_lua 提供的 cosocket API 是非阻塞的,而且这个 API 故意设计成和 LuaSocket 库基本兼容,所以你把 
Lua 社区里那些基于 LuaSocket 的 Lua 库移植到 ngx_lua 环境中,也不会很费劲。

然而没有用,作者提供的cosocket在nginx的上下文使用是有限制的,所以对于需要在nginx初始化时候通过init_by_lua 部分 利用tcp获取一些启动数据的应用来说还是需要安装的,不过https://www.nginx.com/resources/wiki/modules/lua/里面 todo的列表里作者已经提出了  cosocket: add support in the context of init_by_lua. 这个目标,坐等实现。

参考 https://groups.google.com/forum/#!topic/openresty/GPgAH-75gX8

lua-resty-mysql 使用的是 ngx_lua 的 TCP cosocket API,而这个 API 在 init_by_lua 的上下文中是禁用的: http://wiki.nginx.org/HttpLuaModule#ngx.socket.tcp 注意 ngx.socket.tcp 这个接口支持的上下文(Context)列表中并没有 init_by_lua.

同时,lua-resty-mysql 库的文档中对此也有提及:https://github.com/agentzh/lua-resty-mysql#limitations

引用一下原文,“This library cannot be used in code contexts like set_by_lua*, 
log_by_lua*, and header_filter_by_lua* where the ngx_lua cosocket API 
is not available.”

安装完毕,nginx位于/opt/openresty/nginx/路径下,可以各种配置了。

三 nginx error_log 和  ngx.log api

nginx配置会有一个error_log属性,比如下面

error_log  /opt/logs/nginx/error/ng_err.log;

这个日志是nginx本身产生的日志,设置成info级别后在nginx启动时可以看到更多的信息

2015/10/15 16:22:40 [notice] 10439#0: using the "epoll" event method

2015/10/15 16:22:40 [notice] 10439#0: openresty/1.9.3.1

2015/10/15 16:22:40 [notice] 10439#0: built by gcc 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC)

2015/10/15 16:22:40 [notice] 10439#0: OS: Linux 2.6.32-220.el6.x86_64

2015/10/15 16:22:40 [notice] 10439#0: getrlimit(RLIMIT_NOFILE): 65536:65536

2015/10/15 16:22:40 [notice] 10440#0: start worker processes

2015/10/15 16:22:40 [notice] 10440#0: start worker process 10441

2015/10/15 16:22:40 [notice] 10440#0: start worker process 10442

2015/10/15 16:22:40 [notice] 10440#0: start worker process 10444

2015/10/15 16:22:40 [notice] 10440#0: start worker process 10445

2015/10/15 16:22:40 [notice] 10440#0: start worker process 10446

2015/10/15 16:22:40 [notice] 10440#0: start worker process 10447

2015/10/15 16:22:40 [notice] 10440#0: start worker process 10448

...........................

另外还有一种log是在nginx lua模块调用ngx.log(log_level, ...) api接口时产生的err.log,这个日志位于nginx 目录logs文件夹下,调用ngx.log() api

输出的日志都在这个文件里

												

openresty nginx 安装过程记录的更多相关文章

  1. nginx安装过程,报错处理:make[1]: *** [objs/addon/src/bson.o] Error 1

    nginx安装过程中,经常会有各种错误: 具体安装步骤这里不做说明,网上一搜大把: 主要分析安装过程中遇到的问题 在make编译的时候,若报如下错误: cc1: warnings being trea ...

  2. Ubuntu14.04 Tomcat 安装过程记录

    Ubuntu14.04 Tomcat 安装过程记录 检查java的版本 zhousp@ubuntu:~$ sudo java -version [sudo] password for zhousp: ...

  3. openvswitch 2.7 安装过程记录 总结

    envswitch 2.7 安装过程记录 总结 安装思路是参考文档: http://docs.openvswitch.org/en/latest/intro/install/general/#obta ...

  4. zabbix 3.0.3 (nginx)安装过程中的问题排错记录

    特殊注明:安装zabbix 2.4.8和2.4.6遇到2个问题,如下:找了很多解决办法,实在无解,只能换版本,尝试换(2.2.2正常 | 3.0.3正常)都正常,最后决定换3.0.3 1.Error ...

  5. linux环境中,nginx安装过程

    需求描述: 记录在linux平台,nginx安装的过程. 环境描述: 操作系统:Red Hat Enterprise Linux Server release 6.6 (Santiago) 操作内核版 ...

  6. Hadoop集群中pig工具的安装过程记录

    在Hadoop环境中安装了pig工具,安装过程中碰到了一些问题,在此做一下记录:   主要安装流程参考:http://www.cnblogs.com/yanghuahui/p/3768270.html ...

  7. VMware vSphere HyperVisor安装过程记录

      作者:sdjnzqr 出处:http://www.cnblogs.com/sdjnzqr/ 版权:本文版权归作者和博客园共有 转载:欢迎转载,但未经作者同意,必须保留此段声明:必须在文章中给出原文 ...

  8. Red5 1.0.5安装过程记录

    Red5从旧的服务器切换到了github上后,截至20150702仍未更新文档.为了搭建Red5开发环境,我像无头苍蝇一样乱转了很多博客和StackOverflow.藉此记录这次安装过程,希望能够帮助 ...

  9. VMware vSphere虚拟化-VMware ESXi 5.5组件安装过程记录

    几种主要的虚拟化 ESXi是VMware公司研发的虚拟机服务器,ESXi已经实现了与Virtual Appliance Marketplace的直接整合,使用户能够即刻下载并运行虚拟设备.这为 即插即 ...

随机推荐

  1. 那些常用的eclipse快捷键

    用了很久的eclipse了,有些快捷键常用,有的偶尔使用,现在记下常用的快捷键,以便大家和自己查用(持续更新) 这些快捷键都可以在[window]-[preferences]-[general]-[k ...

  2. iOS 获取通讯录里边的电话号码AddressBook

    1  首先导入库 <AddressBook/AddressBook.h> 2 然后在导入#import <AddressBook/AddressBook.h>文件 3 声明   ...

  3. What is SaaS?

    SaaS, or Software as a Service, describes any cloud service where consumers are able to access softw ...

  4. 原生JS判断密码强弱

    前些天工作中有这个需求,自己手写了相关的JS代码,第一种方法是通过ASCII 码判断密码类型,完成用户注册时判断用户输入密码的强度,分强.弱.中三等级,它可以根据用户输入的密码显示对应的密码强弱等级, ...

  5. 【POJ2886】【线段树】Who Gets the Most Candies?

    Description N children are sitting in a circle to play a game. The children are numbered from 1 to N ...

  6. centos 7 samba相关命令

    1.安装相关包 yum install samba samba-client samba-common 2.启动smb的命令 systemctl enable smb.service systemct ...

  7. js获取返回首页

    <script>setTimeout(function(){    window.location.href="http://"+window.location.hos ...

  8. Windows Open with Sublime Text

    Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text] "Icon&q ...

  9. JS Math.sin() 与 Math.cos() 用法

    Math.sin(x)      x 的正玄值.返回值在 -1.0 到 1.0 之间: Math.cos(x)    x 的余弦值.返回的是 -1.0 到 1.0 之间的数: 这两个函数中的X 都是指 ...

  10. ps批量修改图片

    批量更改图片尺寸的ps脚本 高端干货!PHOTOSHOP实用脚本大合集