search
HomeBackend DevelopmentPHP TutorialThe most comprehensive PHP server performance optimization configuration solution

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;


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
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
The Continued Use of PHP: Reasons for Its EnduranceThe Continued Use of PHP: Reasons for Its EnduranceApr 19, 2025 am 12:23 AM

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python: Exploring Their Similarities and DifferencesPHP and Python: Exploring Their Similarities and DifferencesApr 19, 2025 am 12:21 AM

PHP and Python are both high-level programming languages ​​that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP and Python: Different Paradigms ExplainedPHP and Python: Different Paradigms ExplainedApr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP and Python: A Deep Dive into Their HistoryPHP and Python: A Deep Dive into Their HistoryApr 18, 2025 am 12:25 AM

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

Choosing Between PHP and Python: A GuideChoosing Between PHP and Python: A GuideApr 18, 2025 am 12:24 AM

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP and Frameworks: Modernizing the LanguagePHP and Frameworks: Modernizing the LanguageApr 18, 2025 am 12:14 AM

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHP's Impact: Web Development and BeyondPHP's Impact: Web Development and BeyondApr 18, 2025 am 12:10 AM

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

How does PHP type hinting work, including scalar types, return types, union types, and nullable types?How does PHP type hinting work, including scalar types, return types, union types, and nullable types?Apr 17, 2025 am 12:25 AM

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values ​​and handle functions that may return null values.

See all articles

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

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment