启动测试报错:
nginx: error while loading shared libraries: libluajit-5.1.so.2: cannot open shared object file: No such file or directory
我在网上寻找解决办法,找了三个办法 直接使用方法三,如果还是依旧报错在使用方法一
===========================================================================================
解决方法一
在 Nginx 编译时,需要指定 RPATH,加入下面选项即可:
./configure --with-ld-opt="-Wl,-rpath,$LUAJIT_LIB"
或者
export LD_LIBRARY_PATH=/usr/local/lib/:$LD_LIBRARY_PATH
vi /etc/profile
export LD_LIBRARY_PATH=/usr/local/lib/:$LD_LIBRARY_PATH
source /etc/profile
解决方法二:
# ln -s /usr/local/lib/libluajit-5.1.so.2 /lib64/libluajit-5.1.so.2
解决方法三: 这才搞定
#ln -s /usr/local/lib/libluajit-5.1.so.2 /usr/lib/libluajit-5.1.so.2
#ln -s /usr/local/lib/libluajit-5.1.so.2.0.2 /usr/lib/libluajit-5.1.so.2.0.2
再次nginx –t 检查nginx配置 OK
===========================================================================================
4.安装lua
PS:如果上面安装了luaJit这里依旧需要安装lua,原因还没深究
首先安装lua的依赖包
sudo apt-get install libreadline5
apt-get install libreadline-gplv2-dev
下载lua源码
tar -zxvf lua-5.2.3.tar.gz
cd lua-5.2.3/
make linux
make install
5.配置
nginx nginx-lua GraphicsMagick ngx_cache_purge安装完毕后,我们来修改配置文件 如下:
添加三个个location
第一个location用作图片,第二个location用作html,第三个location用作承接第一个location,第四个location用作承接第三location 内容如下:
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html index.htm;
location / {
}
############################################################################################
location /images/ {
set $image_root /usr/local/tfsimage;
if ($uri ~* "/images/([0-9a-zA-Z_]+).(([^.]+).*)") {
set $filePath "$image_root/$1.$2";
set $reqPath "/$1.$2";
set $filename "$1.$3";
}
set $file "$image_root$reqPath";
set $fileone "$image_root/$filename";
if (-f $file) {
rewrite "/images/(.+)" /innerImages$reqPath last;
}
if (!-f $file){
rewrite_by_lua '
--------------------------------------------------------------------------------
//为了避免在nginx服务器上产生太多垃圾图片,在下载原图时先进行判断
function file_exists(name) //定义方法file_exists
local f=io.open(name,"r")
if f~=nil then io.close(f) return true else return false end
end ;
if file_exists(ngx.var.fileone) then print("111") else //调用方法file_exists
command = string.format("wget -P /usr/local/tfsimage/http://192.168.1.230/v1/tfs/"..ngx.var.filename) //定义下载命令
os.execute(command)//执行下载命令
end;
--------------------------------------------------------------------------------
local originalUri;
local area;
local index = string.find(ngx.var.filePath, "([0-9]+)x([0-9]+)");
if index==nil then originalUri = ngx.var.filePath;
else
originalUri = string.sub(ngx.var.filePath, 0, index-2);
area = string.sub(ngx.var.filePath, index);
index = string.find(area, "([.])");
area = string.sub(area, 0, index-1);
end
local image_sizes = {"155x155", "400x400","104x104", "50x50", "40x40", "56x56", "172x172","800x600"};
function table.contains(table, element)
for _, value in pairs(table) do
if value == element then
return true
end
end
return false
end
if table.contains(image_sizes, area) then
local command = "gm convert " .. originalUri .. " -thumbnail " .. area .. " -background white -gravity center -extent " .. area .. " " .. ngx.var.file;
os.execute(command);
ngx.req.set_uri("/innerImages" .. ngx.var.reqPath, true);
else
ngx.req.set_uri("/innerImages" .. ngx.var.reqPath, true);
end;
';
}
}
location /html/ {
set $image_root /usr/local/tfshtml;
if ($uri ~* "/html/([0-9a-zA-Z]+).(.*)") {
set $filePath "$image_root/$1.$2";
set $reqPath "/$1.$2";
}
if (-f $filePath) {
rewrite "/html/(.+)" /innerhtml$reqPath last;
}
//由于html不涉及到原文件的问题我们就不做判断性下载
if (!-f $filePath) {
rewrite_by_lua '
command = string.format("wget -P /usr/local/tfshtml/ http://192.168.1.230/v1/tfs/"..ngx.var.reqpath);
os.execute(command);
ngx.req.set_uri("/innerhtml" .. ngx.var.reqPath, true);
';
}
}
location /innerImages {
alias /usr/local/tfsimage;
expires max;
tcp_nodelay off;
tcp_nopush on;
}
location /innerhtml {
alias /usr/local/tfshtml;
expires max;
tcp_nodelay off;
tcp_nopush on;
}
##############################################################################################
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
本文永久更新链接地址:http://www.linuxidc.com/Linux/2014-07/104897.htm
