Lamp server performance optimization techniques accelerated PHP

Source: Internet
Author: User
Tags bz2 config execution http request ini phpinfo zend linux

At present, lamp (Linux + Apache + MySQL + PHP) has developed rapidly in recent years, has become the fact of the Web server standards. In this article, we will introduce the performance optimization techniques for the server based on lamp combination: Accelerate PHP.

Apache server optimization, PHP optimization, mysql optimization

1. Use of Eaccelerator

We above the introduction of the Apache Server optimization, if you have browsed the Web page of PHP, you may find: How the speed of PHP slowly, this is how it? PHP is not known as speed above the response is very fast? It is because the PHP program code to invoke too many function libraries, and these function libraries each call needs to be read by the hard disk, there is no way to improve the speed of PHP execution ah. If we can read these functions in the hard disk to the cache, because the memory speed can be faster than the hard disk. In this way, of course, it can improve the speed of a lot.

2, software download installation:

wget http://internap.dl.sourceforge.net/sourceforge/eaccelerator/eaccelerator-0.9.3.tar.bz2

Tar jxf eaccelerator-0.9.3.tar.bz2

/usr/local/bin/phpize

./configure--enable-eaccelerator=shared--with-php-config=/usr/local/bin/php-config

Make;make Install

Modify the/etc/php.ini file and add the following:

extension= "/path/to/eaccelerator.so"

Eaccelerator.shm_size= "16"

Eaccelerator.cache_dir= "/tmp/eaccelerator"

eaccelerator.enable= "1"

Eaccelerator.optimizer= "1"

Eaccelerator.check_mtime= "1"

eaccelerator.debug= "0"

Eaccelerator.filter= ""

eaccelerator.shm_max= "0"

Eaccelerator.shm_ttl= "0"

eaccelerator.shm_prune_period= "0"

eaccelerator.shm_only= "0"

eaccelerator.compress= "1"

Eaccelerator.compress_level= "9"

Then set up the fast Access Data directory:

Mkdir/tmp/eaccelerator

chmod 0777/tmp/eaccelerator

To start the Apache server anew:

/ETC/RC.D/INIT.D/HTTPD restart

Open the Web page through the Lynx browser to see Figure 7 through Phpinfo (), which means the installation was successful.

  

Figure 7 Eaccelerator Enabled

As you can see from the diagram: Eaccelerator is enabled. Using the AB command: the Apache HTTP Server performance test tool, which is a tool for testing your Apache HTTP server, you can use this tool to specify the number of requests sent to Apache within a unit of time to see how well your Apache and machine fit together. The order is as follows:

/home/apache/bin/ab-c 20-n100–w Http://localhost/phpinfo >1.html

-C: The number of requests sent to the server at the same time, the default state is to execute only one HTTP request at a time.

-N: The number of requests made when a test session was performed.

-W: Print output to HTML table, the default table is two columns n rows of white black box.

Apachebench) of the test data requests per second (hereinafter referred to as RPS) is the number of pages returned by the server each second, after comparing the use of the Eaccelerator page speed significantly faster. Figure 8 Lynx The browser's HTML format test results.

  

Figure 8 HTML format test results

3. Use of Zend Optimizer

Zend Optimizer uses optimized code to improve the execution speed of PHP 4.0 applications. The principle of implementation is to optimize the code that is generated by running the compiler (Run-time Compiler) before it is finally executed. In general, PHP programs that use Zend Optimizer are 40% to 100% faster than those that are not used. This means that visitors to the site can browse the Web more quickly, thus accomplishing more business and creating better customer satisfaction. Faster response also means that hardware investment can be saved and the services provided by the site are enhanced. Therefore, the use of Zend Optimizer, is tantamount to improving the profitability of e-commerce. Zend Optimizer can bring a lot of benefits to PHP users, especially those who run the site. Running a PHP program quickly can significantly reduce the CPU load on the server and reduce the response time by half, which is the time between when the visitor clicks on the link to the server and starts reading the page.

Zend Optimizer installation is a fool, the installation Wizard will automatically modify your choice to PHP.ini to help you start the engine.

Software Download Installation:

wget http://downloads.zend.com/optimizer/3.0.0/ZendOptimizer-3.0.0-linux-glibc21-i386.tar.gz

Gunzip zendoptimizer-3.0.0-linux-glibc21-i386.tar.gz

Tar vxf Zendoptimizer-3.0.0-linux-glibc21-i386.tar

CD zendoptimizer-3.0.0-linux-glibc21-i386

./install

  

Figure 9 Zend Optimizer Installation Wizard

To start the Apache server anew:

/ETC/RC.D/INIT.D/HTTPD restart

Open a Web page to view the diagram already visible through Phpinfo (), which means that the Zend Optimizer installation was successful.

  

Figure Zend Optimizer installation Successful

You can then use the AB command to test again. You can also use Siege (http://www.joedog.org/siege/) for testing, which is a stress testing and evaluation tool designed for web development, which assesses the affordability of applications under pressure: Multiple user concurrent access to a Web site can be configured based on configuration. Record the corresponding time for each user's request process and repeat it under a certain number of concurrent accesses.







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.