|Last Updated||Ratings||Unique User Downloads||Download Rankings|
|2011-07-08 (5 years ago)||67%||Total: 1,385 This week: 1||All time: 2,730 This week: 821|
|php-multi-server 1.0||GNU Lesser Genera...||5.1||Networking, HTTP, PHP 5, Unix|
This class implements an HTTP server written in pure PHP.
Create PHP desktop application
phpMultiServer 1.0.0 lite INTRODUCTION --------------- This is a sample, high-performance HTTP server written in pure PHP. Thanks to various optimizations, this server is able to achieve ~800 HTTP requests/second on a dual core laptop (Core 2 Duo 1.6Ghz). This in turn allows you to create highly efficient PHP scripts with low response times (less than 1ms latency between sending request to launching PHP script). In result this software is sometimes faster than the Apache Server with mod_php which is written in highly efficient C language. Please note: this is just a 'lite', stripped version of the much larger solution, so the source code is not as flexible as in the original software. This little demo is a proof-of-concept and an educational example of network/inter-process programming in PHP. FEATURES ----------- * Supports GET/HEAD HTTP requests. * Highly efficient PHP code (up to 4 concurrent HTTP requests/1 CPU core ratio) * Basic security mechanisms (ie. server drops root privileges after launch, uses realpath() to protect itself against path traversal attacks) * Uses multicore processing (no CPU/memory limits) * Works as a daemon or CLI application. * Supports customizable index file names. * Supports If-Modified-Since header and '403 Not Modified' responses. * Supports some basic MIME types (you can add your own) * Provides configurable preforking mechanism (mimicking Apache HTTPD functionality) REQUIREMENTS --------------- This software works only in CLI (Command Line Interpreter) mode. It needs the root privileges to launch properly (after start phpMultiServer drops it's root privileges and switches it's effective UID to the standard, configurable user). Required PHP extensions: POSIX, Semaphore, PCNTL. CONFIGURATION ---------------- Server settings are stored in the server.php file, in a ServerConfig class. For starters: try to change these settings: ServerConfig::$documentRoot - stores the local path to the webpage directory (ie /home/users/drupal/public_html). ServerConfig::$serverRoot - stores the local path to the HTTP server directory (ie /root/server). ServerConfig::$socketAddress - stores the IP address of the server, which will be used for communication between server and the HTTP clients (ie 127.0.0.1 for localhost or 0.0.0.0 to listen on all available IP's) ServerConfig::$socketPort - stores the port number on which the HTTP server will listen for incoming connections (ie port 80). ServerConfig::$logFile - stores the path of log file used by this HTTP server. ServerConfig::$user, ServerConfig::$group - stores UID/GID of the unprivileged user, which will be used by the HTTP server (ie nobody/nobody) There is a bunch of other low level options too (documented in the sourcecode). HOW TO LAUNCH ---------------- Unpack the class, enter the class home directory and type below commands using the root privileges: php -f server.php start - starts the HTTP server (daemon mode) php -f server.php stop - stops the HTTP server php -f server.php debug - launches HTTP server in debug mode PRO VERSION -------------- Professional version includes additional functionalities like: * Gzip/deflate compression, POST requests and CGI support in HTTP wrapper. * Flexible source code (support for plugins and various protocols) * Supports various communication protocols (FTP/MySQL connection pooler/PDO proxy/POP3/IMAP/SMTP,SQLite over network) * Even more efficient PHP code. * SOAP server mode (with WSDL generator)
|Version Control||Unique User Downloads||Download Rankings|