In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly shows you "how to make the PHP engine run fast". The content is simple and clear. I hope it can help you solve your doubts. Let the editor lead you to study and learn this article "how to make the PHP engine run fast".
I. Code optimization
When it comes to code optimization, you may think of neat and straightforward code, but this article is not meant to be here, because if you are looking for speed, you need to adjust the PHP source code accordingly. Generally speaking, it is to remove the extra comments and make the code unreadable. But this is simply unthinkable for a programmer with good quality. Fortunately, ZendTechnologies has released the Zend optimization engine to help you do this. It's free now, but you have to follow the Zend Optimizer license. This product can optimize the intermediate code generated by the engine.
It is relatively easy to install this engine. After downloading the version of the corresponding platform, unzip the compressed file, then add the following two lines to the php.ini file, restart the Web server, and you are done.
Zend_optimizer.optimization_level=15 zend_extension= "/ path/to/ZendOptimizer.so" zend_loader.enable=Off
If it is the Win32 platform, it should be:
Zend_optimizer.optimization_level=15 zend_extension_ts= "C:\\ path\\ to\\ ZendOptimizer.dll" zend_loader.enable=Off
In fact, the third line is optional. Because it seems that turning off zend_loader will increase the speed a little bit, it's worth putting this third line into php.ini. It is important to note that the prerequisite for turning off is that you are not using the Zend encryption program.
Second, buffer
If we want to further improve the speed, we need to consider using buffering technology. There are a number of alternative solutions, including Zend Cache (beta version), APC, and Afterburner Cache, as well as jpCache.
All of the above are buffer modules, which store the intermediate code generated by * requests for .php files in the memory of the Web server, and then return the "compiled" version for subsequent requests. Because this reduces disk reads and writes and works in memory, this process can significantly improve application performance. There are more off-the-shelf products, so who do you choose?
Zend Cache is a good commercial product, after loading those large PHP pages, you will obviously feel the speed increase, and the server will set aside more resources. Unfortunately, this product costs money, but in some cases, you should not be stingy with the money.
Afterburner Cache is a product of Bware Technologies, which is currently in the Beta version, and looks like Zend Cashe, but it doesn't work as well as Zend Cache, nor does it work with the Zend optimization engine, but it's free, so I adopted this module.
APC (Alternative PHP Cache) is another free module released by Community Connect and seems to be ready for use in a production environment.
III. Web content compression
For an increasingly congested network, saving bandwidth is as worthy of advocacy as saving water. According to the IETF standard, most browsers should support content compressed using gzip. In other words, you can send the content compressed in gzip to the browser, and the browser will extract the data transparently.
Mod_gzip is a free Apache module released by Remote Communications, which can compress static Web content and send it to browsers. This module is suitable for most static web pages. Although people at Remote Communications say this module supports all the dynamic content generated by mod_php, mod_perl,mod, it still doesn't seem to work, and from mod_gzip 's mailing list, it's estimated that the problem won't be solved until 1.3.14.6f.
If we want to compress dynamic content, we can use class.gzip_encode.php, a PHP class that is used at the beginning and end of the script. For the entire site, it is to call the functions in the auto_prepend and auto_append of php.ini. For more details, you can read the program of this class, which is well annotated and the author has told you almost everything. However, before you use it, your PHP should be compiled to support zlib.
For PHP 5, a new solution is to use ob_gzhandler to achieve the same effect as the above class, as long as you simply add the following sentence to php.ini:
Output_handler = ob_gzhandler
This allows PHP to activate output buffering and compress all output. If there is any special reason not to compress the output of all the content, you can compress the files in the corresponding directory by adding the following line to the .htaccess file.
Php_value output_handler ob_gzhandler
You can also add directly to the PHP code:
Ob_start ("ob_gzhandler")
This compression technique is very effective, but for Netscape Communicator users, because the graphics file cannot be compressed, it does not appear to be fully sent, so you must turn off compression of jpeg and gif files. IE does not have this problem.
The above is all the contents of the article "how to make the PHP engine run fast". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.