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

The most comprehensive PHP server performance optimization configuration solution

php.cn
Release: 2023-03-17 09:26:01
Original
2959 people have browsed it

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!

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template