Home Backend Development PHP Tutorial The most comprehensive PHP server performance optimization configuration solution

The most comprehensive PHP server performance optimization configuration solution

Nov 29, 2017 pm 01:08 PM

If we want to use PHP for development and develop awesome programs, how do we do it? In fact, to develop a program with good performance, the server plays a vital role, so today the editor will share with you a set of

PHP server configuration plan.

[1] Regarding the choice of operating system
The performance of PHP under Linux/FreeBSD is better than that under Windows hosts. If you have no reason to use a Windows host (for example, you need to use ASP.net or SQL Server or Windows Media Server or Serv-U), then I recommend you use Linux/FreeBSD.
If you need to use Windows, it is recommended to use Windows 2003 32-bit Enterprise Edition. Windows 2000 is not recommended (poor performance).
If you need to use Linux, it is recommended to use RedHat Enterprise Linux (the latest version is RedHat Enterprise Linux 4 beta1).
If you need to use FreeBSD, it is recommended to use the latest version FreeBSD 5.2.1.
If your MySQL and Web are separated, it is recommended to use the Linux system for the MySQL host, which can have good performance through LinuxThread (LinuxThread can also be installed under FreeBSD, but it is more troublesome)
[2] About the choice of Web Server
If you are using Windows, it is recommended to use IIS6.0, and Apache is not recommended (poor performance).
If you are using Linux/FreeBSD, it is recommended to use Zeus or Apache (the latest version of Apache is 2.0.52/1.3.33).
Note: The latest version of Zeus, version 4.3, does not yet support FreeBSD version 5.0.
Zeus Web Server is currently the best-performing, fastest, most powerful, most pressure-resistant, and most secure Web server software in the world. However, it is a commercial software and is relatively expensive ( Supporting dual Xeons and enabling hyper-threading costs US$2,200). Cracked versions of Zeus 4.3 for Linux and FreeBSD 4.x can be downloaded online. Many large forums in China, with tens of thousands of people online on a single host, mostly use Zeus, and the system consumption is much smaller than that of Apache. At the same time, Zeus supports server load balancing. Multiple hosts can support super-scale sites by using Zeus Load Balancer.
Zeus’s site is where you can download a 30-day trial version for free (actually, the only difference from the cracked version is the authorization file). For instructions on use, see:
[3] Regarding the choice of PHP running mode

Windows hosts need to install the full version of PHP. You cannot use the installation program provided by php.net to install it, but should install it manually. If you need to use Unicode (UTF-8) encoding, if it is php4.3.x version under Windows host, you need to load the iconv() function library separately (extension_dir needs to be set correctly in php.ini, such as extension_dir = "C:/php/ extensions/"
, and you need to cancel the ";" in front of the line ";extension=php_iconv.dll", and copy c:/php/dlls/iconv.dll to the c:/windows/system32 directory.
Note: The php5.x version does not need and cannot be set like this), and the Linux/FreeBSD host needs to add the iconv parameter (./configure--with-iconv) when compiling PHP.
Under Windows, if you use IIS, it is recommended to use ISAPI to run. Never use CGI to run. You can also use FastCGI (you need to download the FastCGI module and do a lot of configuration), which has better performance. If you use two accelerators (Zend Optimizer, MMCache) at the same time, after testing, it can be close to using Zend Performance under FreeBSD. The effect of Suite, but the stability I tested is relatively poor. When the thread exceeds the maximum concurrent thread limit limited by FastCGI, it may cause the FastCGI process to die at some point, and then cannot access any site. The only solution is to restart the server.
Under Linux/FreeBSD, if you use Apache as the Web Server, it is recommended to run PHP as an Apache module. If you use Zeus as the Web Server, you are required to use FastCGI to run PHP. However, FastCGI may have the problem of dead processes. When stopping zeus, sometimes it will not stop successfully, so that the PIDFILE cannot be cleared. The next time you start FastCGI, Will fail to start. If you encounter a bad gateway error, you need to check whether the PIDFILE is cleared. If not, clear it manually and restart Zeus. The best way is to use crontab to automatically restart FastCGI regularly.
Regarding the problem of FastCGI, it runs normally on some hosts and there will be no problems for several months. But some hosts are more frequent, whether it is Windows or Linux/FreeBSD, it depends on your luck.

[4] Regarding the selection of free PHP accelerators
​​​​
The free accelerators that can be used mainly include Zend Optimizer, Turck MMcache, and ionCube PHP Accelerator.
(1)Zend Optimizer
Official site
Latest version 2.5.5
Download address
(2)Turck MMCache
Official site
Latest version 2.4.6 for PHP v4 .3.4/5.0.0b2
Download address
It should be noted that the latest version of PHP is 4.3.9/5.0.2, so if you need to use Turck MMCache under the latest version of PHP, you need to compile it separately. I have uploaded the files required for the compiled Turck MMCache v2.4.7 CVS for PHP v4.3.9 and Turck MMCache v2.4.7 CVS for PHP v5.0.2 in the attachment of this theme. Install MMCache 2.4.6 first, and then Rename the file in the compressed package I provided to mmcache.dll and replace the old file. Note: these two files are only applicable to Windows hosts. If you need to use it under Linux/FreeBSD, you need to compile MMCache separately.
However, it should be noted that the version of MMCache for PHP5.0.2 has bugs when used under PHP 5.0.2. It is recommended not to use MMCache under PHP5.0.2 for the time being.
(3) ionCube PHP Accelerator (PHPA)
Official site
The latest version 1.3.3r2 builds for PHP 4.3.0
This software can only be used under Solaris/FreeBSD/Linux and does not support Windows , and does not support the latest version of PHP. Zend Optimizer and Turck MMcache support various servers (Windows/Linux/FreeBSD), various Web Servers (IIS/Apache/Zeus) and various versions of PHP. So I don't recommend using this software.
[5] The choice of PHP charging accelerator

The charging accelerator mainly includes Zend Winenabler and Zend Performance Suite.
(1)Zend WinEnabler
Official site
For some unknown reason, Zend official website suddenly deleted all web pages related to this software. Is this software no longer for sale? This is the version of Zend Performance Suite under Windows. It uses FastCGI to run PHP, so the stability is probably not guaranteed.
(2)Zend Performance Suite
Official site
Latest version 4.0
This software can only be used under Linux/FreeBSD and supports Apache and Zeus. It is said that it can increase the speed of PHP programs by 20 times, but the price is relatively expensive, starting at US$1,875. You can download the cracked version online, but it is version 3.6.0/3.5.0 and does not support PHP 5.0. The functionality of Zend Accelerator and earlier Zend Cache are included in this package. Note: If you use this software to cache PHP programs, any modification to the file will require restarting the Web Server to take effect.
[6]About MySQL installation
         
It is recommended to install MySQL version 4.0.x/4.1.x. The latest version is 4.0.22/4.1.17. MySQL 4.0 and above can use Query Cache to greatly improve performance (needs to be set in my.ini). MySQL 4.1 or above adopts a new protocol, which increases the speed by more than 30% and takes up less memory.
For the MySQL4.1.x version, PHP 5.x provides a proprietary mysqli function extension in addition to the original mysql extension to connect to the MySQL4.1.x version. In this way, under MySQL4.1.x, using the mysqli extension is relatively Using the mysql extension can increase the speed of SQL operations dozens of times. The Ultimate Forum program comes with the mysql extension. We also provide the Ultimate Forum mysqli extension module sold separately, which you can purchase and use.
For Windows hosts, just install mysqld-nt. There is no need to use mysqld-max-nt.
Note: If you are running MySQL 4.0.x under Windows, you need to manually perform the following SQL operations on each data table to ensure that your database is stable and does not cause data table errors:

ALTER TABLE table_name type=MyISAM;
Copy after login


Where table_name is the name of the data table.
For Linux hosts, you can install glibc, the latest version is 2.3.3, download address and then install the LinuxThreads inside. You can refer to
For FreeBSD hosts, you can also install LinuxThreads, but compilation is more troublesome.

The article has a lot of content, but if you want to develop the best PHP program, you must learn these optimization solutions, so that the program you develop will be more perfect for you.

The above is the detailed content of The most comprehensive PHP server performance optimization configuration solution. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

7 PHP Functions I Regret I Didn't Know Before 7 PHP Functions I Regret I Didn't Know Before Nov 13, 2024 am 09:42 AM

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? Apr 03, 2025 am 12:03 AM

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

See all articles