ngx_openresty编译安装部署详解

网友投稿 1077 2022-09-28

ngx_openresty编译安装部署详解

ngx_openresty编译安装部署详解

软件简介:

OpenResty (也称为 ngx_openresty)是一个全功能的 Web 应用服务器,它打包了标准的 Nginx 核心,很多的常用的第三方模块,以及它们的大多数依赖项。

OpenResty 通过汇聚各种设计精良的 Nginx 模块,

从而将 Nginx 有效的变成一个强大的 Web 应用服务器,

这样, Web 开发人员可以使用 Lua 脚本语言调动 Nginx 支持的各种C以及Lua 模块,

快速构造出足以胜任 10K+ 并发连接响应的超高性能Web 应用系统.

OpenResty 的目标是让你的Web服务直接跑在 Nginx 服务内部,

充分利用 Nginx 的非阻塞 I/O 模型,

不仅仅对 HTTP 客户端请求,甚至于对远程后端诸如

MySQL,PostgreSQL,~Memcaches 以及 ~Redis 等都进行一致的高性能响

​​-s /sbin/nologin -g -p /usr/local/nginx

mkdir -p /usr/local/pcre

2.软件包-(目前最稳定版本):

wget -p /usr/local/pcre

unzip pcre-8.32.zip

cd pcre-8.32

./configure --prefix=/usr/local/pcre --enable-utf8 --enable-pcregrep-libbz2 --enable-pcregrep-libz

make && make install

3.2:安装ngx_openresty

tar -xvf ngx_openresty-1.4.3.6.tar.gz

cd ngx_openresty-1.4.3.6

./configure --user=--group=--prefix=/usr/local/ --with-pcre --user=--group=--with-luajit --with-file-aio --with- --with---with- --with-pcre=/workspace/pcre-8.32 --with-cc-opt=' -O3'

gmake

gmake install

/etc/init.d/nginx reload

4.nginx调用lua测试配置文件

worker_processes 1;events { worker_connections 1024;}{ include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$' # '"$"$ #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { listen 80; server_name localhost; #access_log logs/host.access.log main;location /echo {default_type 'text/plain';echo 'hello echo';}location /lua {default_type 'text/plain'; content_by_lua 'ngx.say("hello, lua")';}} }5.nginx 启动文件内容#! /bin/sh# chkconfig: 2345 55 25# Description: Startup script for nginx webserver on Debian. Place in /etc/init.d and# run 'update-rc.d -f nginx defaults', or use the appropriate command on your# distro. For CentOS/Redhat run: 'chkconfig --add nginx'### BEGIN INIT INFO# Provides: nginx# Required-Start: $all# Required-Stop: $all# Default-Start: 2 3 4 5# Default-Stop: 0 1 6# Short-Description: starts the nginx web server# Description: starts nginx using start-stop-daemon### END INIT INFO# Author: licess# website: daemon"NAME=nginxDAEMON=/usr/local/nginx/sbin/$NAMECONFIGFILE=/usr/local/nginx/conf/$NAME.confPIDFILE=/usr/local/nginx/logs/$NAME.pidSCRIPTNAME=/etc/init.d/$NAMEset -e[ -x "$DAEMON" ] || exit 0do_start() {$DAEMON -c $CONFIGFILE || echo -n "nginx already running"}do_stop() {kill -INT `cat $PIDFILE` || echo -n "nginx not running"}do_reload() {kill -HUP `cat $PIDFILE` || echo -n "nginx can't reload"}case "$1" instart)echo -n "Starting $DESC: $NAME"do_startecho ".";;stop)echo -n "Stopping $DESC: $NAME"do_stopecho ".";;reload|graceful)echo -n "Reloading $DESC configuration..."do_reloadecho ".";;restart)echo -n "Restarting $DESC: $NAME"do_stopdo_startecho ".";;*)echo "Usage: $SCRIPTNAME {start|stop|reload|restart}" >&2exit 3;;esacexit 0

6,安装报错:

6.1

[root@localhost conf]# /usr/local/nginx/sbin/nginx -t

/usr/local/nginx/sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory

解决方法:在/lib中创建一个symbol link到/usr/local/lib/libpcre.so.1

[root@localhost conf]# ln -s /usr/local/lib/libpcre.so.1 /lib

若出现如下信息,则表示配置正确,否则需按错误提示进行配置文件更正

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok

nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

6.2、启动Nginx服务

#/usr/local/nginx/sbin/nginx

出现告警信息:

nginx: [warn] the "log_format" directive may be used only on "level in /usr/local/nginx/conf/nginx.conf:

这是新版本的问题,需要我们将log_format的定义放到server的前面。如果你是直接更改的nginx.conf文件,你会发现这一句原本就是在server的前面的。

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:linux磁盘性能测试
下一篇:nginx使用cronolog切割日志安装、部署、应用测试
相关文章

 发表评论

暂时没有评论,来抢沙发吧~