Browse Source

Ngx php embeded php in nginx (#4259)

* Add ngx_php

* Update nginx v1.12.2

* Change ubuntu version 18.10 to 16.04

* Running travis...

* Add packet PCRE , php7.2

* Fixed packet php7.2 could not to be installed.

* Fixed packet update.

* Fixed packet add 'add-apt-repository'.

* Add packet php7.2-dev, php7.2-mysql

* Fixed remove 'RUN php-config'

* Fixed add package zlib.

* Fixed add package libargon2-0-dev libsodium-dev

* Fixed not set PHP_LIB .

* Fixed Add package nginx.

php-ngx: nginx: [emerg] open() "/etc/nginx/mime.types" failed (2: No such file or directory) in /deploy/nginx_php.conf:13

* Set default_type and Fixed error.

php-ngx: Warning: Use of undefined constant dbraw - assumed 'dbraw' (this will throw an Error in a future version of PHP) in ngx_php eval code on line 2

* Fixed set dir /php permission.

php-ngx: Warning: include(/php/dbraw.php): failed to open stream: No such file or directory in ngx_php eval code on line 2

* Update nginx_php.conf

* Update fortune location
To send the Content-type from PHP

* Clean php-ngx.dockerfile

* Update to nginx 1.14.2

* Inlcude headers in nginx conf

* Dockerfile silent output

* Use branch
For don't break if we use the master
Joan Miquel 6 years ago
parent
commit
b13ba69974

+ 23 - 0
frameworks/PHP/php/benchmark_config.json

@@ -108,6 +108,29 @@
       "notes": "",
       "notes": "",
       "versus": "php"
       "versus": "php"
     },
     },
+    "ngx": {
+      "plaintext_url": "/hello",
+      "json_url": "/json",
+      "db_url": "/dbraw",
+      "query_url": "/dbraw?queries=",
+      "fortune_url": "/fortune",
+      "update_url": "/updateraw?queries=",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Platform",
+      "database": "MySQL",
+      "framework": "None",
+      "language": "PHP",
+      "flavor": "PHP7",
+      "orm": "Raw",
+      "platform": "None",
+      "webserver": "nginx",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "PHP-raw-ngx",
+      "notes": "ngx_php",
+      "versus": "php"
+    },
     "php5": {
     "php5": {
       "json_url": "/json.php",
       "json_url": "/json.php",
       "plaintext_url": "/plaintext.php",
       "plaintext_url": "/plaintext.php",

+ 73 - 0
frameworks/PHP/php/deploy/nginx_php.conf

@@ -0,0 +1,73 @@
+user www-data;
+worker_processes  auto;
+error_log stderr error;
+worker_rlimit_nofile 200000;
+daemon off;
+
+events {
+    worker_connections 16384;
+	multi_accept on;	 
+}
+
+http {
+    include       /etc/nginx/mime.types;
+    access_log off;
+    server_tokens off;
+
+    sendfile on;
+    tcp_nopush on;
+    tcp_nodelay on;
+    keepalive_timeout 65;
+
+    open_file_cache max=2000 inactive=20s;
+    open_file_cache_valid 60s;
+    open_file_cache_min_uses 5;
+    open_file_cache_errors off;
+
+    php_ini_path /deploy/conf/php.ini;
+
+    server {
+        listen       8080 reuseport;
+        server_name  localhost;
+
+        root /;
+        index  index.html;
+
+        location /hello {
+	        add_header Content-Type text/plain;
+            content_by_php '
+                echo "Hello, World!";
+            ';
+        }
+
+        location /json {
+            add_header Content-Type application/json;
+            content_by_php '
+                echo json_encode(["message" => "Hello, World!"]);
+            ';
+        }
+
+        location /dbraw {
+            add_header Content-Type application/json;
+	        content_by_php '
+                $_GET = ngx::query_args();
+                include "/dbraw.php";
+            ';
+        }
+
+        location /fortune {
+            add_header Content-Type "text/html; charset=UTF-8";
+	        content_by_php '
+                include "/fortune.php";
+            ';
+        }
+
+        location /update {
+            add_header Content-Type application/json;
+	        content_by_php '
+                $_GET = ngx::query_args();
+                include "/updateraw.php";
+            ';
+        }
+    }
+}

+ 29 - 0
frameworks/PHP/php/php-ngx.dockerfile

@@ -0,0 +1,29 @@
+FROM ubuntu:16.04
+
+ARG DEBIAN_FRONTEND=noninteractive
+
+RUN apt-get update -yqq && apt-get install -yqq software-properties-common > /dev/null
+RUN LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php > /dev/null
+RUN apt-get update -yqq  > /dev/null
+RUN apt-get install -yqq wget git unzip libxml2-dev cmake make \
+                    zlibc zlib1g zlib1g-dev libpcre3 libpcre3-dev libargon2-0-dev libsodium-dev \
+                    php7.2 php7.2-common php7.2-dev libphp7.2-embed php7.2-mysql nginx > /dev/null
+
+ADD ./ ./
+
+ENV NGINX_VERSION=1.14.2
+
+RUN git clone -b v0.0.14 --single-branch --depth 1 https://github.com/rryqszq4/ngx_php7.git > /dev/null
+
+RUN wget -q http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz && \
+    tar -zxf nginx-${NGINX_VERSION}.tar.gz && \
+    cd nginx-${NGINX_VERSION} && \
+    export PHP_LIB=/usr/lib && \ 
+    ./configure --user=www --group=www \
+            --prefix=/nginx \
+            --with-ld-opt="-Wl,-rpath,$PHP_LIB" \
+            --add-module=/ngx_php7/third_party/ngx_devel_kit \
+            --add-module=/ngx_php7 > /dev/null && \
+    make > /dev/null && make install > /dev/null
+
+CMD /nginx/sbin/nginx -c /deploy/nginx_php.conf