Phplet installation _php Base under Windows

Source: Internet
Author: User
Tags exit in pear php code sqlite zip

What is Phplet?
It's simple, it's a Web server written in PHP that can replace our usual Apache or IIS.
Why do you want to introduce Phplet?
Because it's a shortcut for Phper to learn the principles of Web servers.
Because of its good program structure, similar to Java object-oriented programming, has a good reference value.
Because I think the Php5+phplet+sqlite (PPS) will be another option for small applications and program demos after PHP5 and Phplet have released a stable version.
Now most of the small application or program demo is the Apache+php+mysql (APM structure) into an EXE or RPM installation package, its capacity in 8m-45m around. If the PPS structure is used, the entire system will be reduced to 2-3m (SQLite is an embedded database) and eliminates the reliance on Apache and MySQL.
How does the Phplet work?
Phplet uses Php_socktes.dll to implement port listening.
The Phplet is resident memory and can be run as NT service using Srvany.exe.
Phplet's multi-process functionality only runs on systems such as Linux, FreeBSD, and *unx systems, because PHP's "Process Control function library" does not support WIN32 platforms.

OK, no more nonsense, immediately into our phplet trip.

I. Resources 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 achieve better performance and stability. I'm using PHP4.3.6, and when I write this document PHP5 is still in the beta phase.
To download the ZIP package instead of installing the package, because the installation version (in fact, the simplified version) does not have the DLL dynamic link library that we need.

L Phplet
zip-format:http://phplet.sourceforge.net/
tgz-format:http://phplet.sourceforge.net/
To download the latest stable version, this will achieve better performance and stability. I'm using PHPlet0.0.7, and I don't have a stable version when I write this document.

Two. Installation:
L PHP

Extract to D:\PHP4:
If you are a beginner it is best to release to the directory I said otherwise it will bring some trouble.
Create Cli_php.exe:
Copy the D:\PHP4\cli\php.exe to the D:\PHP4\cli_php.exe.
It is the Phplet launcher, copied to D:\PHP4 to be able to share php.ini with Php.exe.
Installation of Pear:
Phplet extends Pear's class library, we'll install pear first.
The premise is that your computer is wired, because the installer needs to download a subset of the components (no research has been carried out yet).
In addition, you must be an administrator, because the installer will create Pear.ini in the Windows directory.
After everything is ready, run D:\PHP4\go-pear.bat to start the installation.

First step. Press ENTER directly (or CTRL + C to exit: D):
Welcome to go-pear!

Go-pear would install the ' pear ' command and all of the files needed by
It. This command are your tool for PEAR installation and maintenance.

Go-pear also lets you download and install the Pear packages bundled
With Php:db, Net_socket, NET_SMTP, Mail, Xml_parser, PHPUnit-0.6.2.

If you are wish to abort, press control-c now, or presses Enter to continue:


Step two. Enter pear Download Address:
Used to specify the download address and port of the pear component, you can press ENTER directly.
HTTP Proxy (Http://user:password@proxy.myhost.com:port), or Enter for none::


Step three. PHP Path settings:
A total of 7 items, enter the corresponding serial number can be modified, input "All" is modified all, in general, only need to modify the 7th item.
Selecting item 7th will pop up a Windows Selection Directory dialog box and select D:\PHP4.
Below is a suggested file layout for your new PEAR installation. To
Change individual locations, type the number in front of the
Directory. Type ' All ' to "change all" them or simply press Enter to
Accept 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. Confirms that:
To confirm that some components are installed, enter "Y" here because Phplet is using them.
The following PEAR packages are bundled with Php:db, Net_socket, NET_SMTP,
Mail, Xml_parser, PHPUnit-0.6.2.
Would to install are these as? [y/n]:

&NBSP
5. Install or download components:
Next wait a few minutes, Setup will automatically download the components and install.
If the "PHPUnit-0.6.2" Download errors will be an error, you should check your network connection. (As long as the network normal generally will not be a problem, you can visit http://pear.php.net to try)
Loading zlib:ok
using local Package:pear.............ok
using local Package:archive_tar......ok
using Local Package:console_getopt....ok
Using local Package:xml_rpc..........ok
Bootstrapping:pear ................... (local) OK
Bootstrapping:archive_tar ...... (local) OK
bootstrapping:console_getopt ... (local) OK
using local Package:db...............ok
using local Package:net_socket.......ok
using local Package:net_smtp.........ok the
using local Package:mail.............ok
using local Package:xml_parser.......ok
Downloading package:phpunit-0.6.2 ...

All right, here, pear has been installed.
Modify PHP.ini:
Rename the D:\PHP4\php.ini-dist to php.ini and open it.

Found it:
; Windows: "\path1;\path2"
; include_path = ".; C:\php\includes "
To
; Windows: "\path1;\path2"
include_path = ".;D: \ Php4\includes;d:\php4\pear "

Find: Extension_dir = "./" instead: Extension_dir = "D:\PHP4\extensions\"

Find:; Extension=php_sockets.dll instead: Extension=php_sockets.dll


L Phplet

Extract to D:\PHP4\PHPlet:
If you are a beginner it is best to release to the directory I said otherwise it will bring some trouble.
To change the configuration file:
Open D:\PHP4\PHPlet\config\phplet.conf

"Web_root" modified to: "D:\\php4\\phplet\\www"
"Http_hostname" modified to: "localhost"
"Http_hostport" modified to: "8080"
"Http_server_mode" modified to: "Sequential"
"Http_server_debug" modified to: "false"
"Php_executable" modified to: "D:\\php4\\php.exe"
"Classloader_sintax_check" modified to: "false"
To change the startup file:
Open D:\PHP4\PHPlet\bin\phpletstart.bat

Link:http://www.knowsky.com

"Php_exe" modified to: D:\PHP4\cli_php.exe
Three. Start! Start the server!
Go to D:\PHP4\PHPlet\bin, double-click Phpletstart.bat to start the service.
OK, open the browser input http://localhost:8080/phplet/HelloWorld look at the effect.
Four. Performance test
It is found that just running once, no matter how you modify (or even delete) the helloworld.php, will not change the result of the second refresh (like the Java servlet)? ) Unless you restart the server. So I feel like it's going to be a great performance, as expected, see my test results:
Server A (Php4+phplet), specially selected for the poor AMD k6-2 + 128M.
Client B (windows2003+ie6), p42.6g + 500M
Client b enters the URL http://192.168.0.15:8080/PHPler/HelloWord.php and then presses F5 for 1 minutes, and server A takes up the CPU and continues at 60%. If it is APACHE2+PHP4 (CGI mode) with such a frequency refresh will last 100%, after a long time may be glory virtual memory!

Of course, the above is only one-sided testing, as a Web service is more important or stable, because the time relationship is not a more detailed test. We can do more testing before we discuss it together.
Five. Matters needing attention
1. It says Phplet programming is a bit like a Java Servlet, and it doesn't change the result of a second refresh if you run it once, regardless of whether you make any changes to. PHP (or even delete it).
2. Phplet's Http_hostname (host name) is best set to your IP instead of localhost, otherwise other hosts will not be able to access through your IP.
3. Do not use the exit in the program, to use return exit, otherwise it will shut down the Phplet server.
4. You should enter a string using the $response->write () method because print or echo will output the string to the terminal.
5. Phplet does not support virtual directory and virtual host functionality.
Six. Concluding remarks
Before writing this article did not touch the pear, Phplet and socktes function library, so some terms may not be accurate, welcome to correct me!
Friends who are familiar with Phplet and other Web servers want to communicate with each other, and if you have any questions, you can write to me.

Contribute to the cause of China's PHP----Mausong <maosong@126.com>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.