CentOS7安裝OpenResty

有一個項目是Lua庫寫的,須要部署一個web服務器,考慮Openresty對lua的支持,部署Openresty。html

OpenResty

<p>官方說明:OpenResty® 是一個基於 Nginx 與 Lua 的高性能 Web 平臺,其內部集成了大量精良的 Lua 庫、第三方模塊以及大多數的依賴項。用於方便地搭建可以處理超高併發、擴展性極高的動態 Web 應用、Web 服務和動態網關。</p>nginx

下載地址:

  1. 安裝依賴庫:
$ yum install -y pcre-devel openssl-devel gcc curl
  1. 下載版本:
$ wget https://openresty.org/download/openresty-1.15.8.1.tar.gz
  1. 解壓:
$ tar -xzvf openresty-1.15.8.1.tar.gz
  1. 進入解壓目錄:
$ cd openresty-1.15.8.1/
  1. 檢查配置環境, 生成 Makefile,默認安裝到/usr/local/openresty:
$ ./configure

6.編譯安裝:web

$ gmake && gmake install

安裝結果:shell

mkdir -p /usr/local/openresty/site/lualib /usr/local/openresty/site/pod /usr/local/openresty/site/manifest
ln -sf /usr/local/openresty/nginx/sbin/nginx /usr/local/openresty/bin/openresty

能夠看到openresty 其實是nginx的軟鏈接。服務器

  1. 查看版本號:
$ /usr/local/openresty/bin/openresty -v
nginx version: openresty/1.15.8.3
  1. 啓動:
檢驗配置
/usr/local/openresty/bin/openresty -t
啓動
/usr/local/openresty/bin/openresty
中止
/usr/local/openresty/bin/openresty -s stop
從新加載配置
/usr/local/openresty/bin/openresty -s reload
  1. 配置/lib/systemd/system/openresty.service,經過systemctl啓動:
[Unit]
Description=openresty - high performance web server
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
ExecStart=/usr/local/openresty/bin/openresty -c /usr/local/openresty/nginx/conf/nginx.conf
ExecReload=/usr/local/openresty/bin/openresty -s reload
ExecStop=/usr/local/openresty/bin/openresty -s stop

[Install]
WantedBy=multi-user.target

添加openresty.service後,使配置文件生效:併發

$ systemctl daemon-reload

而後,就能夠使用systemctl管理openresty:curl

啓動
$ systemctl start openresty
中止
$ systemctl stop openresty
重載配置
$ systemctl reload openresty
重啓
$ systemctl restart openresty
相關文章
相關標籤/搜索