ngx_php功能是为nginx模块嵌入php脚本语言。别名为php-nginx-module。
环境
- PHP 5.3. PHP 5.4. PHP 5.5. PHP 5.6. - nginx-1.4.7 nginx-1.6.3 nginx-1.8.1 nginx-1.9.15
安装
git clone https://github.com/rryqszq4/ngx_php.git wget 'http://nginx.org/download/nginx-1.6.3.tar.gz' tar -zxvf nginx-1.6.3.tar.gz cd nginx-1.6.3 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_php/dev/ngx_devel_kit \ --add-module=/path/to/ngx_php
user www www; worker_processes 4; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; keepalive_timeout 65; client_max_body_size 10m; client_body_buffer_size 4096k; php_ini_path /usr/local/php/etc/php.ini; server { listen 80; server_name localhost; location /php { content_by_php ' echo "hello ngx_php"; '; } } }