ngx_php7嵌入 php7 脚本的 nginx 模块
ngx_php7 是一个嵌入 php7 脚本的 nginx 模块。
环境
- Linux only
- PHP-7.0.* ~ PHP-7.4.*
- nginx-1.4.7 ~ nginx-1.17.8
安装
$ wget 'http://php.net/distributions/php-7.3.10.tar.gz' $ tar xf php-7.3.10.tar.gz $ cd php-7.3.10 $ ./configure --prefix=/path/to/php --enable-embed $ make && make install $ git clone https://github.com/rryqszq4/ngx_php7.git $ wget 'http://nginx.org/download/nginx-1.12.2.tar.gz' $ tar -zxvf nginx-1.12.2.tar.gz $ cd nginx-1.12.2 $ export PHP_CONFIG=/path/to/php/bin/php-config $ export PHP_BIN=/path/to/php/bin $ export PHP_INC=/path/to/php/include/php $ export PHP_LIB=/path/to/php/lib $ ./configure --user=www --group=www \ $ --prefix=/path/to/nginx \ $ --with-ld-opt="-Wl,-rpath,$PHP_LIB" \ $ --add-module=/path/to/ngx_php7/third_party/ngx_devel_kit \ $ --add-module=/path/to/ngx_php7 $ make && make install
摘要
worker_processes auto; events { worker_connections 102400; } http { include mime.types; default_type application/octet-stream; keepalive_timeout 65; client_max_body_size 64k; client_body_buffer_size 64k; php_ini_path /usr/local/php/etc/php.ini; server { listen 80; server_name localhost; default_type 'application/json; charset=UTF-8'; location /php { content_by_php_block { echo "hello ngx_php7"; } } location = /ngx_request { content_by_php_block { echo ngx_request_document_uri(); } } # curl /ngx_get?a=1&b=2 location = /ngx_get { content_by_php_block { echo "ngx_query_args()\n"; var_dump(ngx_query_args()); } } # curl -d 'a=1&b=2' /ngx_post location = /ngx_post { content_by_php_block { echo "ngx_post_args()\n"; var_dump(ngx_post_args()); } } location = /ngx_sleep { content_by_php_block { echo "ngx_sleep start\n"; yield ngx_sleep(1); echo "ngx_sleep end\n"; } } location = /ngx_socket2 { default_type 'application/json;charset=UTF-8'; content_by_php_block { $fd = ngx_socket_create(); yield ngx_socket_connect($fd, "hq.sinajs.cn", 80); $send_buf = "GET /list=s_sh000001 HTTP/1.0\r\n Host: hq.sinajs.cn\r\nConnection: close\r\n\r\n"; yield ngx_socket_send($fd, $send_buf, strlen($send_buf)); $recv_buf = ""; yield ngx_socket_recv($fd, $recv_buf); var_dump($recv_buf); yield ngx_socket_close($fd); } } location = /ngx_var { set $a 1234567890; content_by_php_block { $a = ngx_var_get("a"); var_dump($a); } } # set content-type of response headers location = /ngx_header { content_by_php_block { ngx_header_set("Content-Type", "text/html; charset=UTF-8"); } } # run a php file location = /php { content_by_php_block { include "name_of_php_file.php"; } } # run any php file in root location = / { content_by_php_block { include ngx_var_get("uri"); } } } }
评论
ngx_ruby嵌入 ruby 脚本的 Nginx 模块
ngx_rubyngx_ruby是嵌入ruby脚本的Nginx模块。环境ruby-2.3.*nginx-1.6.3+安装$ git clone https://github.com/rryqszq4/
ngx_ruby嵌入 ruby 脚本的 Nginx 模块
0
ngx_ruby嵌入 ruby 脚本的 Nginx 模块
ngx_rubyngx_ruby 是嵌入 ruby 脚本的 Nginx 模块。环境ruby-2.3.
ngx_ruby嵌入 ruby 脚本的 Nginx 模块
0
ngx_php7_tracker追踪 PHP7 运行的 Nginx 模块
ngx_php7_trackerngx_php7的分支,追踪php7脚本运行的opcode、函数栈调用的nginx模块。环境-PHP7.0.* -nginx-1.6.3 安装$ wget http:/
ngx_php7_tracker追踪 PHP7 运行的 Nginx 模块
0
Jx9可嵌入的脚本引擎
Jx9是一个可嵌入的脚本引擎,基于JSON实现了图灵完备(Turingcomplete)的编程语言。Jx9是那些需要流行和高效率脚本支持应用程序(比如:游戏、数据库系统,文本编辑器,网络应用程序等)的
Jx9可嵌入的脚本引擎
0
GoEmPHPGo 嵌入 PHP 脚本
GoEmPHP可以让你在Go程序中嵌入PHP脚本。示例代码:script = php.New()script.Startup()defer script.Close()if err := script
GoEmPHPGo 嵌入 PHP 脚本
0