Phplet installation in Windows

Source: Internet
Author: User
Tags exit in

What is phplet?
It is very simple. It is a web server written in PHP and can replace Apache or IIS.
Why is phplet introduced?
Because it is a shortcut for phper to learn the principles of web servers.
Because of itsProgramThe structure is very good. It is similar to Java object-oriented programming and has good reference value.
I think that after the stable versions of PhP5 and phplet are released one after another, PhP5 + phplet + SQLite (PPS) will be another option for demonstration of small applications and programs.
Currently, most small applications or program demos use Apache + PHP + MySQL (APM structure) as an EXE or RPM installation package, with a capacity of about 8 m-45m. If the PPS structure is used, the entire system will be reduced to 2-3 m (SQLite is an embedded database), and the dependency on Apache and MySQL will be reduced.
How does phplet run?
Phplet uses php_socktes.dll to implement port listening.
Phpletis a resident memory. You can use srvany.exe to run it as an NT Service.
The multi-process function of phplet can only run in Linux, FreeBSD, and * UNX systems. This is because PHP's "process control function library" does not support the Win32 platform.

Now, let's get into our phplet journey right away.

1. Download resources:
L PHP
Zip-format: http://cn.php.net/download/
Tgz-format: http://cn.php.net/download/
To download the latest stable version, you can get better performance and stability. I use php4.3.6. PhP5 is still in the test phase when I write this document.
You need to download the zip package instead of the installation package, because the dynamic dll library is not needed in the installation version (which is a simplified version.

L phplet
Zip-format: http://phplet.sourceforge.net/
Tgz-format: The http://phplet.sourceforge.net/
To download the latest stable version, you can get better performance and stability. I am using phplet0.0.7. There is no stable version at the time of writing this document.

Ii. installation:
L PHP

Decompress the package to D: \ PhP4:
If you are a beginner, it is better to release it to the directory I mentioned. Otherwise, it will cause some troubles in the future.
Create cli_php.exe:
Copy D: \ PhP4 \ CLI \ php.exe to D: \ PhP4 \ cli_php.exe.
It is the phplet Startup Program. Copying to D: \ php4is to share PHP. ini with php.exe.
Pear installation:
Phplet extends the pear class library, so we will first install pear.
The premise is that your computer is connected, because the installer needs to download some components (you have not studied how to not download ).
In addition, your identity must be administrator, because the installation program will create pear. ini in the Windows directory.
After everything is ready, Run D: \ PhP4 \ go-pear.bat to start installation.

Step 1. Press enter directly (or press Ctrl + C to exit: d ):
Welcome to go-pear!

Go-pear will install the 'pear 'command and all the files needed
It. This command is 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 wish to abort, press control-C now, or press enter to continue:

Step 2. Enter pear:
You can press enter to specify the pear component and port.
HTTP proxy (http: // User: password@proxy.myhost.com: port), or enter for none ::

Step 3. php path settings:
For a total of 7 items, enter the corresponding serial number to modify it. If you enter "all", modify all items. Generally, you only need to modify 7th items.
After you select option 2, a windows selection directory dialog box is displayed, and select D: \ PhP4.
Below is a suggested file layout for your new pear installation.
Change individual locations, type the number in front of
Directory. Type 'all' to change all of them or simply press enter
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. Confirm:
Check whether 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.
Wocould you like to install these as well? [Y/n]:

5. install or download components:
Wait a few minutes and the installer will automatically download and install the component.
If an error occurs during the "PHPUnit-0.6.2" download, check your network connection. (As long as the network is normal, there will be no problem, you can access the http://pear.php.net to try)
Loading zlib: OK
Using local package: pear ...... OK
Using local package: archive_tar ...... OK
Using local package: lele_getopt... OK
Using local package: xml_rpc ...... OK
Bootstrapping: pear ...... (local) OK
Bootstrapping: archive_tar ...... OK
Bootstrapping: lele_getopt ...... (local) OK
Using local package: DB ...... OK
Using local package: net_socket... OK
Using local package: net_smtp ...... OK
Using local package: Mail ...... OK
Using local package: xml_parser ...... OK
Downloading package: PHPUnit-0.6.2 ....

Now, pear has been installed.
Modify PHP. ini:
Rename D: \ PhP4 \ PHP. ini-Dist to PhP. ini and open it.

Find:
; Windows: "\ path1; \ path2"
; Include_path = ".; C: \ PHP \ shortdes"
Changed:
; Windows: "\ path1; \ path2"
Include_path = ".; D: \ PhP4 \ des; D: \ PhP4 \ Pear"

Find: extension_dir = "./" to extension_dir = "D: \ PhP4 \ extensions \"

Find:; Extension = php_sockets.dll changed to: Extension = php_sockets.dll

L phplet

Decompress the package to D: \ PhP4 \ phplet:
If you are a beginner, it is better to release it to the directory I mentioned. Otherwise, it will cause some troubles in the future.
Change the configuration file:
Open D: \ PhP4 \ phplet \ config \ phplet. conf

"Web_root" changed to: "d :\\ PhP4 \ phplet \ www"
"Http_hostname" changed to: "localhost"
"Http_hostport" changed to: "8080"
"Http_server_mode" changed to: "sequential"
"Http_server_debug": "false"
"Php_executable" changed to: "d :\\ PhP4 \ php.exe"
"Classloader_sintax_check": "false"
Change the Startup file:
Open D: \ PhP4 \ phplet \ bin \ phpletstart. bat

Link: http://www.knowsky.com

"php_exe" changed to: D: \ PhP4 \ cli_php.exe
3. Start! Start the server!
enter D: \ PhP4 \ phplet \ bin and double-click phpletstart. BAT to start the service.
okay. Open the browser and enter http: // localhost: 8080/phplet/helloworld to check the effect.
4. performance test
it is found that only one operation is required, regardless of the helloworld. PHP does not modify (or even delete) The result of the second refresh (similar to Java Servlet ?), Unless you restart the server. So I think its performance must be good. As expected, please check my test results:
server a (PhP4 + phplet ), especially selected a very bad amd K6-2 400 + 128 M.
client B (Windows2003 + IE6), p42.6g + 500 m
enter the URL http: // 192.168.0.15: 8080/phpler/helloword in client B. PHP then press F5 for 1 minute, and server a occupies 60% of the CPU. If it is apache2 + PhP4 (CGI Mode), the refresh will last for 100% at this frequency, and the virtual memory may be blurred after a long time!

Of course, the above is only a one-sided test. As a web service, it is more stable, because time does not have to be tested in detail. You can do more tests before discussing them.
5. Precautions
1. As mentioned above, phplet programming is a bit similar to Java Servlet. As long as you run it once and make any changes (or even deletes) to. php, it will not change the result of the second refresh.
2. It is best to set the http_hostname (host name) of phplet to your IP address instead of localhost. Otherwise, other hosts cannot access it through your IP address.
3. Do not use exit in the program. Use return to exit. Otherwise, the phplet server will be disabled.
4. The $ response-> write () method should be used to input the string, Because print or ECHO will output the string to the terminal.
5. phplet does not support virtual directories and Vm functions.
Vi. Conclusion
Write this articleArticleI have never touched pear, phplet, and socktes function libraries before, so some terms may not be accurate enough. please correct me!
If you are familiar with phplet and other Web servers, you can write to me if you have any questions.

Contribute to China's PHP career meager strength ---- Mao song <maosong@126.com>

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.