A web server in PHP
By Justin Silverton
Have you ever wanted a web server written entirely in PHP? Now you can with nanoweb. A project like this really shows the power of the PHP language.
Features
- HTTP/1.1 implementation
- Keep-alive connections and cache helpers
- Modular architecture
- CGI and Server side includes support via included modules
- Name based virtual hosts
- Authentication support
- Error documents
- MIME support
- gzip content encoding
- PHP support
- Many other modules
Performance
A report here states the following: “nanoweb reached 101 days of uptime and did not show a single glitch after serving more than 4.1 milion hits and more than 52 GB.”.
Here are some more details:
Static test
This was measured on this server, a duron 700 with 1gb of ram.
The tests were run using ab and consisted of 500 requests (20 simultaneous) on static and dynamic content.
Static content : Server Software: aEGiS_nanoweb/2.0.1-dev
Server Hostname: si.kz Server Port: 80
Document Path: /six.gif
Document Length: 28352 bytes
Concurrency Level: 20
Time taken for tests: 3.123 seconds
Complete requests: 500
Failed requests: 0
Broken pipe errors: 0
Keep-Alive requests: 497
Total transferred: 14496686 bytes
HTML transferred: 14337322 bytes
Requests per second: 160.10 [#/sec] (mean)
Time per request: 124.92 [ms] (mean)
Time per request: 6.25 [ms] (mean, across all concurrent requests)
Transfer rate: 4641.91 [Kbytes/sec]
received Connnection Times (ms) min
mean[+/-sd] median max Connect: 0 0 1.9 0 13
Processing: 18 100 276.4 40 2739
Waiting: 1 97 276.9 39 2739
Total: 18 100 277.8 40 2750
Installing
Unix:
install-sh -f or Run ./install-sh (if you have X-windows installed)
Windows:
Run INSTALL.BAT Note: Performance will not be as good as in unix because PHP does not support process forking in windows.
Download
Nanoweb 2.2.8 can be downloaded here
10 Comments so far
Leave a reply






I didn’t exactly read all of this but I have a question: PHP requires a web server to run so how can you make a web server using PHP without having a web server to install PHP on to?
You can actually run php outside of a web server in both windows and *nix. When your script is executed, the output will go to the console (or command prompt) rather than on a webpage.
You don’t need a web server to execute php code. All you need is a php binary. What you’re thinking is the php module in the Apache server that calls the php binary and spits out the html every time a php page is requested. Did you know you can write command line applications, shell scripts and (with certain pluglins on Linux) GUI programs with php. Its freakin awesome. Oh yeah, you can even write network applications e.g. daemons and control office applications i.e. MS Excell all with php.
Well, not only on Linux you can write GUI programs (PHP-GTK), but also on Windows too - you need WinBinder library for that, it uses native Windows interface for GUI’s, so it’s realy fast also
I first saw this a few years ago… good to see it is still active.
Not sure about production use though, but it sure would make a nice candidate to ship your app with a development server bundled into it, similar to how Rails ships with Webrick bundled in.
Tell me please. For what this need.
Exist many of webserver applications, for example Apache.
As for me, this project interesting as idea.
It show for us, how we can create powerfull deamon application.
Thanks.
“Tell me please. For what this need.
Exist many of webserver applications, for example Apache.”
For most needs, apache will do. This is more of a proof-of-concept (that it is possible to create a usable web server) in PHP.
[…] Ентузіасти мови програмування PHP розробили HTTP/1.1 сумісний web-сервер Nanoweb написаний повністю на PHP. […]
[…] Энтузиасты языка программирования PHP разработали HTTP/1.1 совместимый web-сервер Nanoweb написанный полностью на PHP. […]
[…] Ето, че се е намерила група ентусиасти, написали уеб сървър на PHP. В началото подходих със сериозна доза скептицизъм относно производителността, но тестовете показват, че е доста сносна. Ако тези дни ми остане достатъчно време за губене, евентуално ще го тествам и ще споделя резултатите. […]