整理了一下最近学习openresty的笔记,打算放上来。
OpenResty 是一个基于 Nginx 与 Lua 的高性能 Web 平台,所以安装的时候同样依赖pcre包,openresty包可以到官方网站http://openresty.org/或官方github地址https://github.com/openresty/openresty下载最新的安装包
首先安装依赖包
yum -y install readline-devel pcre-devel openssl-devel gcc
下载pcre-8.39.tar.gz和openresty-1.11.2.1.tar.gz安装包
tar xf pcre-8.39.tar.gz
tar xf openresty-1.11.2.1.tar.gz
cd openresty-1.11.2.1 ./configure --prefix=/usr/local/openrestry --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_gzip_static_module --with-http_stub_status_module --with-pcre=../pcre-8.39
tar xf openresty-1.11.2.1.tar.gz
cd openresty-1.11.2.1 ./configure --prefix=/usr/local/openrestry --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_gzip_static_module --with-http_stub_status_module --with-pcre=../pcre-8.39
make && make install
编写nginx.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
worker_processes 1; error_log logs/error.log; events { worker_connections 1024; } http { server { listen 80; location / { default_type text/html; content_by_lua_block { ngx.say("<p>hello, world</p>") } } } } |
启动openresty
/usr/local/openresty/nginx/sbin/nginx
curl http://localhost
<p>hello, world</p>
OK 安装成功了