A new way called DWS to run php script on nginx 0.8.x !

hightman hightman at zuaa.zju.edu.cn
Sat Oct 9 12:47:36 MSD 2010


PHP-DWS is the abbreviation for "PHP Direct Web Server".  It works much like fastcgi server with nginx, 

But nginx pass the request header of HTTP and socket file description of this connection to it via 
calling sendmsg(), and then PHP-dws read request body data from http connection , send response 
data to the http connection directly.

I simply draw their work in the following flow diagram:

      [PHP-CGI]
      ============
              
            i)request header+body     ii)request header+body
           +~~~~>~~~~>~~~~>~~~+     +~~~~~>~~~~~>~~~~>~~~~~+
           |                  |     |                      |
          /|\                \|/   / \                    \|/
      WebVisitor             Web Server               FastCGIServer
        (user)                (nginx)                  (php-cgi)
          /|\                \ /   /|\                    \ /
           |                  |     |                      |
           +~~~<~~~~<~~~~<~~~~+     +~~~~~<~~~~~<~~~~<~~~~~+
          iv)response header+body    iii)response header+body

      [PHP-DWS]
      ============

                        i)request header           ii)request header
           +~~~~>~~~~>~~~~>~~~+     +~~~~~>~~~~~>~~~~>~~~~~+
           |                  |     |                      |
          /|\                \|/   / \                    \|/
      WebVisitor             Web Server               DWSCGI Server
        (user)                (nginx)                   (php-dws)
       /|\  \ /                                         /|\   \ /
        |    |                                           |     |
        |    +~~~~~~~~>~~~~~~~~~~~~>~~~~~~~~~~~~>~~~~~~~~+     |
        |     iii) request body                                |
        |                                                      |
        +~~~~~~~~~~~~~<~~~~~~~~~~~<~~~~~~~~~~~~~<~~~~~~~~~~~~~~+   
        iv)response header+body

I think that php-dws will save much more IO operator and become more efficient.
In addition, we can send partial data to browser during script running, i.e:
http://root.twomice.net/dws-test/sleep.phpd

Welcome to give me some suggestions or comments! 

===

I have completed the preliminary work, including two part. 

The first is ngx_http_dwsgi_module,  download source codes from:
http://www.hightman.cn/down/nginx_0.8_dwsgi_module_beta1.tgz

Extract it to top source directory of nginx, it will be looked like:
nginx-0.8.x/src/addon/dwsgi/

then recompile the nginx with option: --add-module=src/addon/dwsgi

config sample can be found in src/addon/dwsgi/*.conf


The second is a new sapi module for php, develop under 5.3.3, get the source
code package from: 
http://www.hightman.cn/down/php53_sapi_dws_beta1.tgz

Extract it to top source directory of php5, it will be looked like:
php-5.3.x/sapi/dws/

then run following commands to rebuild the php:
./buildconf --force
./config.nice --disable-fpm --disable-cgi --enable-dws
make && make install

Run $prefix/bin/php-dwsctl to start or stop php-dws, 
or try $prefix/bin/php-dws -h  for more options and its description.



















  

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20101009/e2eece61/attachment.html>


More information about the nginx mailing list