linux上安裝OpenResty(Nginx)

1. 安裝依賴

yum install pcre-devel openssl-devel gcc curl postgresql-devel

2. 下載解壓

#下載
wget -c https://openresty.org/download/openresty-1.15.8.1rc2.tar.gz
#解壓
tar -zxvf openresty-1.15.8.1rc2.tar.gz

3. 源碼編譯

//切換目錄 
cd openresty-1.15.8.1rc2

//開始安裝 ./configure #或者下面,後面是參數 不寫默認就行
./configure 
--prefix=/usr/local/openresty/ 
--with-http_stub_status_module 
--with-luajit 
--without-http_redis2_module 
--with-http_iconv_module 
--with-http_postgres_module 
--with-stream gmake && gmake install

4. 添加環境變量

#打開配置文件
vim /etc/profile
#編寫配置變量 
PATH=/usr/local/openresty/nginx/sbin:$PATH 
export PATH 
#保存退出

#執行生效命令:
source /etc/profile

#查看是否生效:
echo $PATH

查看配置結果  

5. 添加倉庫執行命令 

#加載依賴
yum install yum-utils
#下載repo
yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo

6. 執行安裝

#安裝
yum install openresty
#安裝成功後 會在默認的目錄如下:
/usr/local/openresty

7. 配置nginx

#默認已經安裝好了nginx,在目錄:/usr/local/openresty/nginx下。
#修改/usr/local/openresty/nginx/conf/nginx.conf ,將配置文件使用的根設置爲root,目的就是將來要使
#用lua腳本的時候 ,直接可以加載在root下的lua腳本。

#進入openresty 中nginx
cd  /usr/local/openresty/nginx


#啓動nginx
sbin/nginx -c conf/nginx.conf

#重啓 OpenResty
nginx -s reload 
 

 

 

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