ngx-php - Embedded php7 or php8 scripting language for nginx module. Mainline development version of the ngx-php.
ngx-php - Embedded php7 or php8 scripting language for nginx module. Mainline development version of the ngx-php.
ngx-php is an extension module of high-performance web server nginx, which implements embedded PHP7 and PHP8 script to process nginx location and variables.
ngx-php draws on the design of ngx_lua and is committed to providing non-blocking web services with significant performance advantages over php-cgi, mod_php, php-fpm and hhvm.
ngx-php doesn't want to replace anything, just want to provide a solution.
There is a legacy version of ngx_php5, which records some of my past code practices and is also valuable.
Benchmarks about ngx-php and php
…
yum -y install https://extras.getpagespeed.com/release-el7-latest.rpm
yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm yum-utils
yum-config-manager --enable remi-php73
yum install nginx-module-php7
Edit nginx.conf and load the required modules at the top:
load_module modules/ndk_http_module.so;
load_module modules/ngx_http_php_module.so;
…
https://github.com/rryqszq4/ngx-php/blob/master/docs/zh-cn/osx_install.md
$ docker build -t nginx-php7 .
$ : "app.conf: Create nginx config"
$ docker run -p 80:80 -v $PWD/app.conf:/etc/nginx/conf.d/default.conf nginx-php7
…
Using the perl of Test::Nginx module to testing, searching and finding out problem in ngx-php.
…
syntax: php_ini_path``
context: http
phase: loading-config
This directive allows loading the official php configuration file php.ini, which will be used by subsequent PHP code.
syntax: init_worker_by_php``
context: http
phase: starting-worker
syntax: init_worker_by_php_block{php script code}
context: http
phase: starting-worker
syntax: rewrite_by_php``
context: http, server, location, location if
phase: rewrite
In the rewrite phase of nginx, you can execute inline php code.
syntax: rewrite_by_php_block{php script code}
context: location, location if
phase: rewrite
In the rewrite phase of nginx, you can execute inline php code.
syntax: access_by_php``
context: http, server, location, location if
phase: access
In the access phase of nginx, you can execute inline php code.
syntax: access_by_php_block{php script code}
context: location, location if
phase: access
In the access phase of nginx, you can execute inline php code.
syntax: content_by_php``
context: http, server, location, location if
phase: content
In the content phase of nginx, you can execute inline php code.
syntax: content_by_php_block{php script code}
context: location, location if
phase: content
In the content phase of nginx, you can execute inline php code.
syntax: log_by_php``
context: http, server, location, location if
phase: log
syntax: log_by_php_block{php script code}
context: location, location if
phase: log
syntax: header_filter_by_php``
context: http, server, location, location if
phase: output-header-filter
syntax: header_filter_by_php_block{php script code}
context: location, location if
phase: output-header-filter
syntax: body_filter_by_php``
context: http, server, location, location if
phase: output-body-filter
syntax: body_filter_by_php_block{php script code}
context: location, location if
phase: output-body-filter
syntax: php_keepalive``
default: 0
context: http, server
In php, set upstream connection pool size.
syntax: php_set$variable ``
context: http, server, location, location if
phase: loading-config
Installs a php handler for the specified variable.
syntax: php_socket_keepalive``
default: 0
context: http, server
syntax: php_socket_buffer_size``
default: 4k
context: http, server, location, location if
syntax: ngx_exit(int $status) : void
parameters:
status: intcontext: rewrite_by_php*, access_by_php*, content_by_php*
End of current request and return http status code.
syntax: ngx_query_args(void) : array or ngx::query_args(void) : array
parameters:
voidcontext: rewrite_by_php*, access_by_php*, content_by_php*
An associative array of variables passed to the current script via the URL parameters (aka. query string).
Instead of php official constant $_GET.
syntax: ngx_post_args(void) : array or ngx::post_args(void) : array
parameters:
voidcontext: rewrite_by_php*, access_by_php*, content_by_php*
An associative array of variables passed to the current script via the HTTP POST method
when using application/x-www-form-urlencoded or multipart/form-data as the HTTP Content-Type in the request.
Instead of php official constant $_POST.
syntax: ngx_log_error(int $level, string $log_str) : void or ngx_log::error(int $level, string $log_str) : void
parameters:
level: intlog_str: stringcontext: rewrite_by_php*, access_by_php*, content_by_php*
syntax: ngx_request_method(void) : string or ngx_request::method(void) : string
parameters:
voidcontext: rewrite_by_php*, access_by_php*, content_by_php*
Which request method was used to access the page, such as 'GET','POST','PUT','DELETE' and so on.
syntax: ngx_request_document_root(void) : string or ngx_request::document_root(void) : string
parameters:
voidcontext: rewrite_by_php*, access_by_php*, content_by_php*
The document root directory under which the current script is executing, as defined in the server's configuration file.
syntax: ngx_request_document_uri(void) : string or ngx_request::document_uri(void) : string
parameters:
voidcontext: rewrite_by_php*, access_by_php*, content_by_php*
syntax: ngx_request_script_name(void) : string or ngx_request::script_name(void) : string
parameters:
voidcontext: rewrite_by_php*, access_by_php*, content_by_php*
Contains the current script'path. This is useful for pages which need to point to the themselves.
The FILE constant contains the full path and filename of the current (included) file.
syntax: ngx_request_script_filename(void) : string or ngx_request::script_filename(void) : string
parameters:
voidcontext: rewrite_by_php*, access_by_php*, content_by_php*
The absolute pathname of the currently executing script file name.
syntax: ngx_request_query_string(void) : string or ngx_request::query_string(void) : string
parameters:
voidcontext: rewrite_by_php*, access_by_php*, content_by_php*
The query string, if any, via which the page was accessed.
syntax: ngx_request_uri(void) : string or ngx_request::uri(void) : string
parameters:
voidcontext: rewrite_by_php*, access_by_php*, content_by_php*
The URI which was given in order to access this page, for instance, '/index.html'.
syntax: ngx_request_server_protocol(void) : string or ngx_request::server_protocol(void) : string
parameters:
voidcontext: rewrite_by_php*, access_by_php*, content_by_php*
Name and revision of th information protocol via which the page was requested, such as 'HTTP/1.0'.
syntax: `ngx_request_remote_addr(void) :
No open issues yet, or sync has not completed.