CentOS7安裝OpenResty

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

OpenResty

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

下載地址:

  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.編譯安裝:

$ gmake && gmake install

安裝結果:

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:

啓動
$ systemctl start openresty
停止
$ systemctl stop openresty
重載配置
$ systemctl reload openresty
重啓
$ systemctl restart openresty

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章