|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
欢迎大家来到仓酷云论坛!假如你将跑在Windows下的项目(如:php)迁徙到Linux下,因为Windows操纵体系中,文件名是不辨别巨细写的;而Linux体系是巨细写敏感,会招致有些网页呈现404情形。
办理***有也许4种:
1、urlrewrite
2、perl模块
3、lua模块
4、ngx_http_lower_upper_case
第一种***合用于有划定规矩的大概较少的url必要转换,假如有大批并没有划定规矩的请用上面几种***
第2、3、四种***条件是Linux体系当地文件是小写,道理是将url哀求转换成小写来处置
perl模块(不保举!Nginx官网已声名perl模块存在内存毛病的大概),***以下(《lnmp一键装置包》装置后实行上面):- cdlnmp/src/nginx-1.4.4makeclean#扫除已编译出的nginx#/usr/local/nginx/sbin/nginx-V#猎取已编译参数nginxversion:nginx/1.4.4builtbygcc4.4.720120313(RedHat4.4.7-3)(GCC)TLSSNIsupportenabledconfigurearguments:--prefix=/usr/local/nginx--user=www--group=www--with-http_stub_status_module--with-http_ssl_module--with-http_flv_module--with-http_gzip_static_module--with-ld-opt=-ljemalloc
复制代码 在已编译的参数前面加上–with-http_perl_module,以下:- ./configure--prefix=/usr/local/nginx--user=www--group=www--with-http_stub_status_module--with-http_ssl_module--with-http_flv_module--with-http_gzip_static_module--with-ld-opt=-ljemalloc--with-http_perl_module
复制代码 大概会报以下毛病:- CantlocateExtUtils/Embed.pmin@INC(@INCcontains:/usr/local/lib64/perl5/usr/local/share/perl5/usr/lib64/perl5/vendor_perl/usr/share/perl5/vendor_perl/usr/lib64/perl5/usr/share/perl5.).BEGINfailed--compilationaborted../configure:error:perlmoduleExtUtils::Embedisrequired
复制代码 办理***(CentOS):- yum-yinstallperl-develperl-ExtUtils-Embed
复制代码 再次编译:- makeclean./configure--prefix=/usr/local/nginx--user=www--group=www--with-http_stub_status_module--with-http_ssl_module--with-http_flv_module--with-http_gzip_static_module--with-ld-opt=-ljemalloc--with-http_perl_modulemakecp/usr/local/nginx/sbin/nginx/usr/local/nginx/sbin/nginx$(date+%m%d)#备份nginx原文件servicenginxstopmakeinstall#间接装置,假如只掩盖nginx,会有报错/usr/local/nginx/sbin/nginx-t
复制代码 修正设置主文件(/usr/local/nginx/conf/nginx.conf):- perl_set$urlsub{my$r=shift;my$re=lc($r->uri);return$re;};
复制代码 修正假造主机设置文件(如:/usr/local/nginx/conf/vhost/demo.linuxeye.com.conf):- if($uri~[A-Z]){rewrite^(.*)$$urllast;}
复制代码 lua模块(保举!)
lua-nginx-module来自信牛agentzh的开源项目,在Nginx中嵌进Lua言语,使之能够撑持壮大Lua语法,以下:- cdlnmp/srcwgethttp://luajit.org/download/LuaJIT-2.0.2.tar.gzwgethttps://github.com/simpl/ngx_devel_kit/archive/v0.2.19.tar.gz#ngx_devel_kitwgethttps://github.com/chaoslawful/lua-nginx-module/archive/v0.9.2.tar.gz#nginx_lua_moduletarxzfLuaJIT-2.0.2.tar.gztarxzfv0.2.19.tar.gztarxzfv0.9.2.tar.gzcdLuaJIT-2.0.2make&&makeinstallexportLUAJIT_LIB=/usr/local/libexportLUAJIT_INC=/usr/local/include/luajit-2.0
复制代码- cdnginx-1.4.4makeclean#扫除已编译出的nginx#/usr/local/nginx/sbin/nginx-V#猎取已编译参数nginxversion:nginx/1.4.4builtbygcc4.4.720120313(RedHat4.4.7-3)(GCC)TLSSNIsupportenabledconfigurearguments:--prefix=/usr/local/nginx--user=www--group=www--with-http_stub_status_module--with-http_ssl_module--with-http_flv_module--with-http_gzip_static_module--with-ld-opt=-ljemalloc
复制代码 从头编译Nginx:- ./configure--prefix=/usr/local/nginx--user=www--group=www--with-http_stub_status_module--with-http_ssl_module--with-http_flv_module--with-http_gzip_static_module--with-ld-opt=-ljemalloc--add-module=../lua-nginx-module-0.9.2--add-module=../ngx_devel_kit-0.2.19makecp/usr/local/nginx/sbin/nginx/usr/local/nginx/sbin/nginx$(date+%m%d)#备份nginx原文件servicenginxstopmakeinstall#间接装置,假如只掩盖nginx,大概会报错ldconfig#从头读取库文件,不然报错/usr/local/nginx/sbin/nginx-t
复制代码 修正设置文件(如:/usr/local/nginx/conf/vhost/demo.linuxeye.com.conf):- ./configure--prefix=/usr/local/nginx--user=www--group=www--with-http_stub_status_module--with-http_ssl_module--with-http_flv_module--with-http_gzip_static_module--with-ld-opt=-ljemalloc--with-http_perl_module0
复制代码 ngx_http_lower_upper_case模块
参考:https://github.com/replay/ngx_http_lower_upper_case
如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的好朋友们! |
|