国产亚洲精品福利在线无卡一,国产精久久一区二区三区,亚洲精品无码国模,精品久久久久久无码专区不卡

當(dāng)前位置: 首頁 > news >正文

旬陽做網(wǎng)站湖南seo快速排名

旬陽做網(wǎng)站,湖南seo快速排名,長春南京小學(xué)網(wǎng)站建設(shè),嘉興網(wǎng)站建設(shè)運營安裝OpenResty 1.安裝 首先你的Linux虛擬機必須聯(lián)網(wǎng) 1)安裝開發(fā)庫 首先要安裝OpenResty的依賴開發(fā)庫,執(zhí)行命令: yum install -y pcre-devel openssl-devel gcc --skip-broken2)安裝OpenResty倉庫 你可以在你的 CentOS 系統(tǒng)中…

安裝OpenResty

1.安裝

首先你的Linux虛擬機必須聯(lián)網(wǎng)

1)安裝開發(fā)庫

首先要安裝OpenResty的依賴開發(fā)庫,執(zhí)行命令:

yum install -y pcre-devel openssl-devel gcc --skip-broken

2)安裝OpenResty倉庫

你可以在你的 CentOS 系統(tǒng)中添加 openresty 倉庫,這樣就可以便于未來安裝或更新我們的軟件包(通過 yum check-update 命令)。運行下面的命令就可以添加我們的倉庫:

yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo

如果提示說命令不存在,則運行:

yum install -y yum-utils 

然后再重復(fù)上面的命令

3)安裝OpenResty

然后就可以像下面這樣安裝軟件包,比如 openresty

yum install -y openresty

4)安裝opm工具

opm是OpenResty的一個管理工具,可以幫助我們安裝一個第三方的Lua模塊。

如果你想安裝命令行工具 opm,那么可以像下面這樣安裝 openresty-opm 包:

yum install -y openresty-opm

5)目錄結(jié)構(gòu)

默認(rèn)情況下,OpenResty安裝的目錄是:/usr/local/openresty

在這里插入圖片描述

看到里面的nginx目錄了嗎,OpenResty就是在Nginx基礎(chǔ)上集成了一些Lua模塊。

6)配置nginx的環(huán)境變量

打開配置文件:

vi /etc/profile

在最下面加入兩行:

export NGINX_HOME=/usr/local/openresty/nginx
export PATH=${NGINX_HOME}/sbin:$PATH

NGINX_HOME:后面是OpenResty安裝目錄下的nginx的目錄

然后讓配置生效:

source /etc/profile

2.啟動和運行

OpenResty底層是基于Nginx的,查看OpenResty目錄的nginx目錄,結(jié)構(gòu)與windows中安裝的nginx基本一致:

在這里插入圖片描述

所以運行方式與nginx基本一致:

# 啟動nginx
nginx
# 重新加載配置
nginx -s reload
# 停止
nginx -s stop

nginx的默認(rèn)配置文件注釋太多,影響后續(xù)我們的編輯,這里將nginx.conf中的注釋部分刪除,保留有效部分。

修改/usr/local/openresty/nginx/conf/nginx.conf文件,內(nèi)容如下:


#user  nobody;
worker_processes  1;
error_log  logs/error.log;events {worker_connections  1024;
}http {include       mime.types;default_type  application/octet-stream;sendfile        on;keepalive_timeout  65;server {listen       8081;server_name  localhost;location / {root   html;index  index.html index.htm;}error_page   500 502 503 504  /50x.html;location = /50x.html {root   html;}}
}

在Linux的控制臺輸入命令以啟動nginx:

nginx

然后訪問頁面:http://192.168.150.101:8081,注意ip地址替換為你自己的虛擬機IP:

3.備注

加載OpenResty的lua模塊:

#lua 模塊
lua_package_path "/usr/local/openresty/lualib/?.lua;;";
#c模塊     
lua_package_cpath "/usr/local/openresty/lualib/?.so;;";  

common.lua

-- 封裝函數(shù),發(fā)送http請求,并解析響應(yīng)
local function read_http(path, params)local resp = ngx.location.capture(path,{method = ngx.HTTP_GET,args = params,})if not resp then-- 記錄錯誤信息,返回404ngx.log(ngx.ERR, "http not found, path: ", path , ", args: ", args)ngx.exit(404)endreturn resp.body
end
-- 將方法導(dǎo)出
local _M = {  read_http = read_http
}  
return _M

釋放Redis連接API:

-- 關(guān)閉redis連接的工具方法,其實是放入連接池
local function close_redis(red)local pool_max_idle_time = 10000 -- 連接的空閑時間,單位是毫秒local pool_size = 100 --連接池大小local ok, err = red:set_keepalive(pool_max_idle_time, pool_size)if not ok thenngx.log(ngx.ERR, "放入redis連接池失敗: ", err)end
end

讀取Redis數(shù)據(jù)的API:

-- 查詢redis的方法 ip和port是redis地址,key是查詢的key
local function read_redis(ip, port, key)-- 獲取一個連接local ok, err = red:connect(ip, port)if not ok thenngx.log(ngx.ERR, "連接redis失敗 : ", err)return nilend-- 查詢redislocal resp, err = red:get(key)-- 查詢失敗處理if not resp thenngx.log(ngx.ERR, "查詢Redis失敗: ", err, ", key = " , key)end--得到的數(shù)據(jù)為空處理if resp == ngx.null thenresp = nilngx.log(ngx.ERR, "查詢Redis數(shù)據(jù)為空, key = ", key)endclose_redis(red)return resp
end

開啟共享詞典:

# 共享字典,也就是本地緩存,名稱叫做:item_cache,大小150m
lua_shared_dict item_cache 150m; 
http://m.aloenet.com.cn/news/32190.html

相關(guān)文章:

  • 網(wǎng)站前端設(shè)計網(wǎng)絡(luò)營銷案例分析報告
  • 福州網(wǎng)站制作案例石家莊百度快照優(yōu)化排名
  • 聊天app開發(fā)源碼搜索引擎優(yōu)化seo專員
  • 國外域名查詢網(wǎng)站2021年10月新聞?wù)?/a>
  • 屬于網(wǎng)頁制作平臺蘭州seo優(yōu)化
  • 合肥網(wǎng)站關(guān)鍵詞好網(wǎng)站
  • 3g網(wǎng)站開發(fā)怎么在百度上投放廣告
  • 動態(tài)網(wǎng)站開發(fā)語言優(yōu)勢需要留電話號碼的廣告
  • 阿里云企業(yè)網(wǎng)站備案制作網(wǎng)頁一般多少錢
  • 武漢企業(yè)宣傳片制作公司保定seo推廣外包
  • 深圳做網(wǎng)站設(shè)計公司營銷策略包括哪些內(nèi)容
  • 網(wǎng)站app開發(fā)建設(shè)關(guān)鍵詞在線查詢
  • 淳化網(wǎng)站制作福州網(wǎng)站快速排名提升
  • 胖咯科技網(wǎng)站建設(shè)百度小說風(fēng)云榜
  • 深圳住房建設(shè)廳網(wǎng)站首頁搜索量查詢
  • wordpress 刷新緩存太原百度關(guān)鍵詞優(yōu)化
  • 重復(fù)打開同一個網(wǎng)站怎么做軟文推廣多少錢
  • 技術(shù)支持 湖州網(wǎng)站建設(shè)百度怎么發(fā)布自己的信息
  • 泉州企業(yè)網(wǎng)站建設(shè)批量查詢指數(shù)
  • 自己有個服務(wù)器 怎樣做網(wǎng)站推廣普通話手抄報文字
  • 我們的網(wǎng)站長沙網(wǎng)站制作公司哪家好
  • 微信php網(wǎng)站開發(fā)流程人民網(wǎng) 疫情
  • 網(wǎng)絡(luò)工作室起名seo主管招聘
  • 學(xué)建網(wǎng)站 必須學(xué)那些知識seo網(wǎng)絡(luò)推廣優(yōu)化
  • 聊城網(wǎng)站建設(shè)上饒seo博客
  • 廣安市國土資源局網(wǎng)站建設(shè)推廣通
  • ps做網(wǎng)站主頁圖片怎樣在百度上免費做廣告
  • 購物網(wǎng)站設(shè)計目的小吳seo博客
  • ssp網(wǎng)站怎么做最快新聞資訊在哪看
  • 云南房產(chǎn)網(wǎng)站建設(shè)seo基礎(chǔ)入門教程