PHPLET installation under Windows
What is phplet?
Very simple, it is a web server written in PHP, which can replace our common Apache or IIS.
Why introduce phplet?
Because it is a shortcut that PHPER learns the principle of Web server.
Because its program structure is very good, there is a good reference value similar to the object-oriented programming of Java.
Because I think PHP5 and phpleton have released a stable version, PHP5 PHPLET SQLITE (PPS) will be a small application, and another option for program demonstration.
Most of the small applications or program demonstrations are all EXE or RPM installation packages to the Apache PHP MySQL (APM structure), which is about 8m to 45m. If the entire system is used to use the PPS structure, it will be reduced to 2-3m (SQLite is an embedded database), and the dependence on Apache and MySQL will be saved.
PHPLET's way of operation?
PHPLET uses PHP_SOCKTES.DLL to implement port listens. Phplet is resident memory, you can run it as NT service using SRVANy.exe. The multifunction function of the phplet can only run in Linux, FreeBSD, * UNX system, etc., because PHP's "process control library" does not support Win32 platforms.
Ok, not much nonsense, go to our phplet tour immediately.
1. Resource Download:
l
PHP
Zip-Format:
http://cn.php.net/download/
TGZ-Format:
http://cn.php.net/download/
To download the latest stable version, this will get better performance and stability. I use php4.3.6, and PHP5 is still in the test phase when writing this document.
To download the zip package, it is not a installation package, because the installation version (actually a simplified version) does not have the DLL dynamic link library we need.
l phplet
Zip-Format:
http://phplet.sourceforge.net/
TGZ-Format:
http://phplet.sourceforge.net/
To download the latest stable version, this will get better performance and stability. I use phplet0.0.7, there is no stable version when writing this document.
Second. Installation:
l php
Unzip to D: / PHP4:
If you are an initiator, it is best to release the directory I said, otherwise it will bring some trouble.
Create a CLI_PHP.EXE:
Copy D: /PHP4/CLI/Php.exe to D: /PHP4/Cli_php.exe.
It is a PHPLET launch program, copied to D: / PHP4 to share php.ini with php.exe.
PEAR installation:
The phplet expands the PEAR class library, then let's install the PEAR first.
The premise is that your computer is connected, because the installer needs to download a part of the component (not studying how to download).
In addition, your identity must be Administrator because the Pear.ini is created in the Windows directory in the installer.
Everything is ready to run D: /PHP4/go-pear.bat after going to install.
The first step. Press the Enter directly (you can also exit: d): D):
Welcome to go-pear!
GO-Pear Will Install the 'pear' Command and all the files needed by the command is your Tool for pear installation and maintenance.
Go-pear also lets you download and install the PEAR packages bundledwith PHP: DB, Net_Socket, Net_SMTP, Mail, XML_Parser, PHPUnit-0.6.2.If you wish to abort, press Control-C now, or press Enter to continue:
Step 2. Enter the PEAR download address:
Used to specify the download address and port of the Pear component, you can press the Enter directly.
HTTP proxy (http:// user: password@proxy.myhost.com: port), or enter for none ::
The third step. PHP path setting:
A total of 7 items, enter the corresponding serial number to modify, enter "all" is all modified, and only the seventh item needs to be modified.
When you select seventh item, a Windows selection directory dialog box will pop up, select D: / PHP4.
Below is a suggested file layout for your new PEAR installation. Tochange individual locations, type the number in front of thedirectory. Type 'all' to change all of them or simply press Enter toaccept these locations.
1. Installation prefix: D: / PHP4 2. Binaries directory: $ prefix 3. PHP code directory ($ php_dir): $ prefix / pear 4. Documentation base directory: $ php_dir / docs 5. Data base directory: $ php_dir / data 6. Tests Base Directory: $ PHP_DIR / TESTS 7. PHP.EXE PATH:
1-7, 'All' or Enter to Continue:
4. Confirm:
Confirm that some components are installed, here is "Y", because phplet is being used by them.
The Following Pear Packages Are bundled with php: db, net_socket, net_smtp, mail, xml_parser, phpUnit-0.6.2.would you like to install these as well? [Y / N]:
5. Install or download components:
Next, please wait a few minutes, the installer automatically downloads the components and installs.
If the "phpUnit-0.6.2" download error will report an error, then check your network connection. (As long as the network is usually generally no problem, you can visit
http://pear.php.net
Try
Loading Zlib: Okusing Local Package: Pear ........... Okusing local package: Archive_tar ... Okusing local package: console_getopt .... Okusing local package: XML_RPC .... ... okbootstrapping: pear ................. (local) okbootstrapping: Archive_Tar ......... (local) okbootstrapping : Console_getopt ......... (local) Okusing local package: db ............. Okusing local package: net_socket ....... Okusing local package: Net_smtp ......... okusing local package: mail ........... Okusing local package: XML_PARSER ....... okdownloading package: phpUnit-0.6.2 .. .. Ok, I have been installed here.
Modify PHP.INI:
Rename D: /PHP4/php.ini-dist is php.ini and then open.
turn up:
Windows: "/ Path1; / Path2"; Include_path = ".; C: / php / incrudes"
Change to:
Windows: "/ Path1; / path2" incrude_path = ".; D: / PHP4 / Includes; D: / PHP4 / PEAR"
Found: extension_dir = "./" change to: extension_dir = "d: / php4 / extensions /"
Found:; extension = php_sockets.dll change to: extension = php_sockets.dll
l phplet
Unzip to D: / PHP4 / phplet:
If you are an initiator, it is best to release the directory I said, otherwise it will bring some trouble.
Change the configuration file:
Open d: / php4/phplet/config/phplet.conf
"Web_root" is modified to: "D: // php4 // phplet // www"
"Http_hostname" is modified to: "Localhost"
"Http_hostport" is modified to: "8080"
"Http_server_mode" modified to: "Sequential"
"Http_server_debug" is modified to: "false"
"PHP_EXECUTABLE" is modified to: "D: //php4//php.exe"
"ClassLoader_Sintax_Check" is modified to: "false"
Change the boot file:
Open d: / php4/phplet/bin/phpletstart.bat
"Php_exe" is modified to: D: /PHP4/Cli_php.exe
3. Start! Start the server!
Go to D: / PHP4 / phplet / bin, double-click the phpletstart.bat boot service. Ok, open your browser.
Http: // localhost: 8080 / phplet / helloworld
Look at the effect.
Four. Performance Test
I found that as long as I run once, no matter what modification (or even delete) is made to HelloWorld.php, it will not change the result of the second refresh (like the Java Servlet is like it?) Unless the server is restarted. So I feel that it is very good, I don't expect it, please see my test results:
Server A (PHP4 phplet), specially selected a very bad AMD K6-2 400 128M.
Client B (Windows2003 IE6), P42.6G 500M
Client B Enter URL
Http://192.168.0.15:8080/phpler/helloword.php
Then press and hold F5 for 1 minute, the server A occupies the CPU continues to 60%. If it is apache2 php4 (CGI mode), it will last 100% in such a frequency, and it may be stamped in virtual memory after the time is long!
Of course, the above is just a one-sided test, as a web service is more important to stabilize, because the time relationship has no effort more detailed test. Everyone can discuss together after more testing.
5. Precautions
1. The phplet programming is a bit similar to the Java servlet, as long as you run any changes to .php, do any changes (or even delete), or change the result of the second refresh.
2. PHPLET's http_hostname is preferably set to your IP instead of localhost, otherwise other hosts cannot access your IP.
3. Don't use exit in the program, you want to use Return to exit, otherwise the phplet server will be turned off.
4. You should enter the string with a $ response-> write () method because print or Echo outputs strings to the terminal.
5. The phplet does not support virtual directory and virtual hosting.
Six. Conclusion
Write this article until you have exposed to Pear, phplet, and socktes function libraries, so some terms may be not accurate enough, welcome to correct!
Friends familiar with phplet and other web servers hopes to communicate with each other if you have any questions, you can write to me.
Contributing to China's PHP career contributes its own meager power ---- Musy