LAMP (Linux + Apache + Mysql + PHP) optimization skills

Source: Internet
Author: User
Article Title: LAMP (Linux + Apache + Mysql + PHP) optimization skills. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

[LAMP platform]

The term LAMP first came from the German Magazine "c't Magazine". In 1990, Michael Kunze first combined these projects to create the abbreviation of LAMP. Although these components are not designed for use at the beginning, these open-source software can be easily obtained at any time and free of charge. As a result, these components are often used together. Over the past few years, the compatibility of these components has been constantly improved, and the application situation has become very general. Some extension functions have been created to improve collaboration between different components. Currently, almost all Linux releases contain "LAMP stack" by default. These products form a powerful Web application platform

The LAMP platform is composed of four components and has a hierarchical structure. Each layer provides a key part of the entire software stack:

  • Linux:Linux is at the lowest layer and provides the operating system. Each other component is actually running on Linux. However, it is not necessarily limited to Linux. If necessary, other components can also be stored in Microsoft®Windows®Mac OS X or UNIX®.
  • Apache:The lower layer is Apache, which is a Web server. Apache provides a mechanism for users to obtain Web pages. Apache is a stable server that supports key tasks. Over 65% of websites on the Internet use Apache as a Web server. PHP components are actually in Apache, and dynamic pages can be created through Apache and PHP.
  • MySQL:MySQL provides the data storage end of the LAMP system. With MySQL, you can obtain a very powerful database suitable for running large and complex sites. In Web applications, all data, products, accounts, and other types of information are stored in this database, which can be easily queried using the SQL language.
  • PHP:PHP is a simple and effective programming language. It is like an adhesive that can bond all other components of the LAMP system together. You can use PHP to write dynamic content that can access MySQL database data and some features provided by Linux.

[Detection tool]

To obtain the complete debugging results, we recommend that you use software such as ApacheBench or httperf. If you are interested in non-LAMP server testing, we recommend that you use Microsoft's Free Software: Web Application Stress Tool (NT or 2000 required ). (Other server testing tools)
Detects Apache and uses top d 1 to display the CPU and memory of all processes. In addition, the apachectl status Command is also used.

[Hardware optimization]

1. General hardware upgrade rules: For PHP scripts, the main bottleneck is CPU, and for static pages, the bottleneck is memory and network. The Static Page downloaded by a 400 Mhz ordinary Pentium machine can make the T3 leased line (45 Mbps) saturated.

2. hdparm is used to optimize disks. Generally, the read/write performance of the IDE disk is improved by 200%, but it also has an effect on the SCSI hard disk. (Comparison of hard disks of different types)

  [Policy optimization]

  3. Apache processes PHP scripts 2-10 times slower than static pages, so try to use more static pages and fewer scripts.

4. If PHP scripts are not buffered, compilation is required for each call. Therefore, installing a PHP buffer product can improve the performance by 25-100%.

5. If you use a Linux system, we recommend that you upgrade the kernel to 2.4 because the static page is served by the kernel.

6. Another Buffer technology is to use HTML buffer output for infrequently modified PHP pages.

7. Do not run X-Windows on the Web server, and disable unnecessary processes.

8. If you can use text, do not use images. Minimize the image size.

9. Distribute the load and put the database server on another machine. If all static pages are processed on another server, you can set KeepAlives in httpd. conf to off to reduce the disconnection time.

10. All the above methods are for standalone servers. If you think the system is not fast enough, you can use the cluster, Server Load balancer, and buffering technologies. Use Squid as the buffer and configure Squid.

[1] [2] [3] Next page

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.