Install and use Nginx extension Web server OpenResty

Source: Internet
Author: User
Tags lua mysql client web services

OpenResty, also known as "ngx_openresty", is a core Nginx-based Web application server. It contains a large number of third-party Nginx modules and most system dependent packages. OpenResty is not a branch of Nginx, but a software package. There are mainly chapter Yichun maintenance.

Why is it OpenResty?

OpenResty allows developers to use lua programming language to build an existing Nginx C module and support high-traffic applications.

Install OpenResty

Dependent software package:

Perl 5.6.1 +
Libreadline
Libpcre
Libssl

Debian and Ubuntu systems:
Apt-get install libreadline-dev libncurses5-dev libpcre3-dev libssl-dev perl make

Fedora, RedHat, and centos systems:
Yum install readline-devel pcre-devel openssl-devel

Download OpenResty

Wget http://openresty.org/download/ngx_openresty-1.5.8.1.tar.gz.

Decompress, compile, and install:

Tar xzvf ngx_openresty-1.5.8.1.tar.gz
Cd ngx_openresty-1.5.8.1/
./Configure -- with-luajit
Make
Make install

Other configuration options:

./Configure -- prefix =/opt/openresty
-- With-luajit
Without-http_redis2_module
With-http_iconv_module
With-http_postgres_module
-J2
-- Help to see more options

References:

Official: http://openresty.org/
Github: https://github.com/agentzh/ngx_openresty


Expansion of OpenResty for Web servers based on Nginx found on the Internet



OpenResty aggregates a variety of well-designed Nginx modules to effectively convert Nginx into a powerful Web application server, web developers can use the Lua scripting language to mobilize various C and Lua modules supported by Nginx to quickly construct an ultra-high-performance Web application system that is competent for 10 K + concurrent connection responses.
 
The goal of OpenResty is to allow your Web services to run directly inside the Nginx service and make full use of the non-blocking I/O model of Nginx, not only for HTTP client requests, but also for remote backend such as MySQL, postgreSQL ,~ Memcaches and ~ Redis and so on all perform consistent high-performance response.
 
OpenResty: http://openresty.org/
OpenResty official website: http://openresty.org/cn/
Nginx Wikipedia: http://wiki.nginx.org/
 
Note:
The installation of OpenResty is relatively simple. Here we need to use a powerful function, that is, using nginx to directly access mysql, retrieve data, and return it to the browser. There are two methods: Use the HttpDrizzleModule, libdrizzle 1.0 (in drizzle) also needs to be installed. The second is to use the ngx_lua module and the lua library lua-resty-mysql (Mysql client Driver ). When OpenResty is installed by default, some lua libraries are installed, such
 
Regardless of the method used, install the pcre library libpcre, which is required for nginx installation.
[Root @ vm5 ~] # Yum install pcre-devel.x86_64

Method 1
 
1. Install libdrizzle 1.0
[Root @ vm5 ~] # Wget http://agentzh.org/misc/nginx/drizzle7-2011.07.21.tar.gz
[Root @ vm5 ~] # Tar zxvf drizzle7-2011.07.21.tar.gz
[Root @ vm5 ~] # Cd drizzle7-2011.07.21
[Root @ vm5 drizzle7-2011.07.21] #./configure -- without-server
[Root @ vm5 drizzle7-2011.07.21] # make libdrizzle-1.0
[Root @ vm5 drizzle7-2011.07.21] # make install-libdrizzle-1.0
 
2. Install OpenResty
[Root @ vm5 ~] # Wget http://openresty.org/download/ngx_openresty-1.2.4.14.tar.gz
[Root @ vm5 ~] # Tar zxvf ngx_openresty-1.2.4.14.tar.gz
[Root @ vm5 ~] # Cd ngx_openresty-1.2.4.14
[Root @ vm5 ngx_openresty-1.2.4.14] #./configure -- prefix =/usr/local/openresty -- with-luajit -- with-http_drizzle_module -- with-libdrizzle =/usr/local
[Root @ VMware ngx_openresty-1.2.4.14] # gmake
[Root @ VMware ngx_openresty-1.2.4.14] # gmake install
 
3. Create test data
Mysql> create table users (id int, username varchar (30), age tinyint );
Query OK, 0 rows affected (0.00 sec)

Mysql> insert into users values (1, 'hangsan', 24 );
Query OK, 1 row affected (0.00 sec)

Mysql> insert into users values (2, 'lisi', 26 );
Query OK, 1 row affected (0.00 sec)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.