需要安装readline-devel
centos : yum install readline-devel debian : apt-get install readline-devel |
安装nginx和lua
./configure --with-luajit \ --with-http_realip_module \ --with-http_addition_module \ --with-http_dav_module \ --with-http_ssl_module \ --with-http_flv_module \ --with-http_gzip_static_module \ --with-http_stub_status_module \ --with-pcre=/root/software/pcre-8.20 |
nginx的配置说明
参数详解: --prefix #nginx安装目录,默认在/usr/local/nginx --user=nginx #运行nginx的用户 --group=nginx #运行nginx的用户组 --pid-path #pid问件位置,默认在logs目录 --lock-path #lock问件位置,默认在logs目录 --with-http_ssl_module #开启HTTP SSL模块,以支持HTTPS请求。 --with-http_dav_module #开启WebDAV扩展动作模块,可为文件和目录指定权限 --with-http_flv_module #支持对FLV文件的拖动播放 --with-http_realip_module #支持显示真实来源IP地址 --with-http_gzip_static_module #预压缩文件传前检查,防止文件被重复压缩 --with-http_stub_status_module #取得一些nginx的运行状态 --with-mail #允许POP3/IMAP4/SMTP代理模块 --with-mail_ssl_module #允许POP3/IMAP/SMTP可以使用SSL/TLS --with-pcre=../pcre-8.11 #指定未安装的pcre路径 --with-zlib=../zlib-1.2.5 #注意是未安装的zlib路径 --with-debug #允许调试日志 --http-client-body-temp-path #客户端请求临时文件路径 --http-proxy-temp-path #设置http proxy临时文件路径 --http-fastcgi-temp-path #设置http fastcgi临时文件路径 --http-uwsgi-temp-path #设置uwsgi 临时文件路径 --http-scgi-temp-path #设置scgi 临时文件路径 |
nginx.conf
user nginx nginx; worker_processes 8; error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; gzip on; include nginx.servers.conf; } |
php.location.conf
index index.html index.htm index.php; location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)$ { expires 1h; } location ~ \.php$ { if ($request_filename ~* (.*)\.php) { set $php_url $1; } if (!-e $php_url.php) { return 403; } fastcgi_pass phpfastcgi; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ ^/(fpmstatus|fpmping)$ { fastcgi_pass phpfastcgi; fastcgi_param SCRIPT_FILENAME $fastcgi_script_name; include fastcgi_params; access_log off; } |
lua.location.conf
location /echo { default_type text/plain; echo hello lua; } location /lua { default_type text/plain; content_by_lua 'ngx.say("hello world")'; } |
访问 http://127.0.0.1:81/lua 会得到hello world
访问 http://127.0.0.1:81/echo 会得到hello lua