VMware Workstation Centos7 搭建开发环境
1. 虚拟机centos7,设置桥接,实现联网2.yum安装nginxyum install nginx安装完成后,查找下安装目录,find / -iname nginx启动nginx /usr/sbin/nginx
1. 虚拟机centos7,设置桥接,实现联网
2.yum安装nginx
yum install nginx
安装完成后,查找下安装目录,
find / -iname nginx
启动nginx /usr/sbin/nginx
3.nginx启动后 其他机器(非本机)无法访问,
CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙步骤。
1、关闭firewall:
systemctl stop firewalld.service #停止firewall
4.Nginx正确记录post日志
放到任意Location里面。
具体步骤如下:
1,安装LuaJIT
wget http://luajit.org/download/LuaJIT-2.0.1.tar.gz
tar -zxvf LuaJIT-2.0.1.tar.gz
make PREFIX=/data/apps/luajit2.0.1
make install PREFIX=/data/apps/luajit2.0.
2,下载并解压以下两个个模块
http://github.com/simpl/ngx_devel_kit/tags
http://github.com/chaoslawful/lua-nginx-module/tags
把解压后的2个目录分别移动到 /usr/local/src/ 目录下面(个人习惯而已)
3,重新编译Nginx
export LUAJIT_LIB=/data/apps/luajit2.0.1/lib
export LUAJIT_INC=/data/apps/luajit2.0.1/include/luajit-2.0
./configure --prefix=/data/apps/nginx --add-module=/usr/local/src/ngx_devel_kit-0.2.19 --add-module=/usr/local/src/lua-nginx-module-0.9.2
make -j2
make install
4,然后在需要记录post日志的Location里面加上如下语句:
lua_need_request_body on;
content_by_lua 'local s = ngx.var.request_body';
log_format post_log '$remote_addr - $request_body';
5,在启动Nginx的时候如果报错:
error while loading shared libraries: libluajit-5.1.so.2: cannot open shared object file: No such file or directory
解决:
ln -s /data/apps/luajit2.0.1/lib/libluajit-5.1.so.2 /lib64/libluajit-5.1.so.2
参考文档:
http://www.cnblogs.com/meteorx/p/3188647.html
http://wiki.nginx.org/HttpLuaModule#Synopsis
更多推荐
所有评论(0)