Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to compile a high performance OpenResty

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article is about how to compile a high-performance OpenResty, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

Introduction

Here's how to manually compile OpenResty,OpenResty step by step, a high-performance Web platform based on Nginx and Lua, which has a very good scalability to allow the server to perform better. All rely on the dependencies in the build of the Linux distribution, eliminating the post-compilation maintenance costs.

Prepare to set up security groups (important)

If you don't set up a security group, you can't tell whether it is inaccessible or failed to compile.

Need to be open: ports 80 and 443

Tutorials

This tutorial takes Ubuntu 16.04 LTS 64-bit Edition as an example.

Set version variable

If the software version is updated, for convenience, you only need to modify the following variables to modify the version number. In the SSH terminal, enter:

# VersionOpenSSLVersion='openssl-1.0.2l';NginxCTVersion='1.3.2';PageSpeedVersion='1.12.34.2';SystemBit='X64';OpenRestyVersion='openresty-1.11.2.5'

Note: as of this update, OpenResty version 1.11.2 can only be paired with OpenSSL 1.0.2 at most.

Update view of the above software version: OpenSSL, Nginx-CT, PageSpeed, OpenResty

Installation dependency

Update the system software source cache and upgrade the components:

Apt updateapt upgrade-y

Install dependent components:

Download the source code for apt install build-essential libreadline-dev libncurses5-dev libpcre3 libpcre3-dev libssl-dev zlib1g-dev unzip git perl make libjemalloc1 libjemalloc-dev

Here, all the source code required for OpenResty is placed in the / root/src directory for easy management.

Cd / rootmkdir srccd src

Download the source code for OpenResty and its extensions:

# download OpenSSL Ubuntu 16.04 (not included) Please delete the following # to download # wget https://www.openssl.org/source/$OpenSSLVersion.tar.gz#tar xzf $OpenSSLVersion.tar.gzwget https://github.com/grahamedgecombe/nginx-ct/archive/v$NginxCTVersion.tar.gztar xzf v$NginxCTVersion.tar.gzgit clone https://github.com/google/ngx_brotli.gitcd ngx_brotligit submodule update-- initcd.. / wget https://github.com/pagespeed/ngx_pagespeed / archive/v$PageSpeedVersion-beta.zipunzip v$PageSpeedVersion-beta.zipcd ngx_pagespeed-$PageSpeedVersion-beta/wget https://dl.google.com/dl/page-speed/psol/$PageSpeedVersion-$SystemBit.tar.gztar-xzvf $PageSpeedVersion-$SystemBit.tar.gzcd.. / wget-c https://openresty.org/download/$OpenRestyVersion.tar.gztar zxf $OpenRestyVersion.tar.gz

See more.

Compile OpenRestycd $OpenRestyVersion./configure-- prefix=/usr/local/openresty\-- user=www-data-- group=www-data\-- add-module=../ngx_brotli\-- add-module=../nginx-ct-$NginxCTVersion\-- add-module=../ngx_pagespeed-$PageSpeedVersion-beta\-- with-http_v2_module\-- with-http_ssl_module\-- with-http_gzip_static_module\-- with-ld-opt='-ljemalloc'make & & make install

Ubuntu 16.04 (not included) the following versions should be added on the penultimate line:

-- with-openssl=../$OpenSSLVersion\ set variable [- z "`grep ^ 'export PATH=' / etc/ profile`] & & echo" export PATH=/usr/local/openresty/nginx/sbin:\ $PATH "> > / etc/profile [- n" `grep ^' export PATH=' / etc/profile `"- a-z" `grep / usr/local/openresty/ / etc/ profile` "] & & sed-I" s@ ^ export PATH=\ (. *\) @ export PATH=/usr / local/openresty/nginx/sbin:\ 1 @ "/ etc/profile. / etc/profile

Later, you can use nginx-t to check whether the configuration is correct, and nginx-s reload overloads Nginx.

Create related directories mkdir / data/wwwlogs/-pmkdir / data/wwwroot/default/-pcp / usr/local/openresty/nginx/html/index.html / data/wwwroot/default/ setup service and boot

Create a / etc/systemd/system/openresty.service file with the contents:

Cd / etc/systemd/system/wget https://gist.githubusercontent.com/ivmm/dbf03e6c7970488652878bb8ddc3a775/raw/48436d911d08e57774c759bdb50548dec31dc86f/openresty.service

The edit / usr/local/openresty/nginx/conf/nginx.conf file is:

Cd / usr/local/openresty/nginx/conf/rm nginx.conf-rfwget https://gist.githubusercontent.com/ivmm/ab81dee184b64036bd4b8d5abe676264/raw/1cbfbc387aa956f6d9afe39d60e2b8c988a10688/nginx.conf

Reload the systemd service so that it can find our files:

Systemctl daemon-reload

Restart OpenResty via systemd:

Systemctl restart openresty

Set up boot boot:

Systemctl enable openresty

Open your server IP and you will see the installed OpenResty prompt page https://pics.mf8.biz/mf8/awxi3.pngcdn.com/137e540c5e3ae5cf31758fbee7062cfcbac7399e.png">

The above is how to compile a high-performance OpenResty. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 239

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report