The most comprehensive PHP server performance optimization configuration scheme

Source: Internet
Author: User
Tags mysql host php server ioncube zend
If you want to use PHP to develop, and want to develop a very good program, then how exactly do we do it? In fact, the development of a good performance program, the server plays a vital role, then today's small editors for everyone to share a set of

PHP Server configuration scenarios.

[1] about the selection of the operating system
PHP performs better under LINUX/FREEBSD than under Windows host. If you do not have a 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 that you use LINUX/FREEBSD.
If you need to use Windows, it is recommended to use Windows 2003 32-bit Enterprise Edition, which is not recommended for Windows 2000 (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 of FreeBSD 5.2.1.
If your MySQL and web separation, MySQL host recommended the use of Linux system, through the linuxthread can be very good performance (Linuxthread can also be installed under FreeBSD, but more cumbersome)
[2] about the web Server Selection
If you are using Windows, it is recommended to use IIS6.0, which is not recommended for Apache (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 4.3 does not yet support the FreeBSD 5.0 release. The
Zeus Web server is the world's best-performing, fastest, most powerful, best-in-breed Web server software with the highest security, but it's commercial software that costs more ($ 2200 to support dual Xeon enabled Hyper-threading), and the Web can be downloaded to Zeus cracked version of 4.3 for Linux and FreeBSD 4.x. Many large-scale domestic forums, single-host online tens of thousands of people mostly use Zeus, system consumption is much smaller than Apache. While Zeus supports server load balancing, multiple hosts can support a super-scale site by using the Zeus load balancer. The
Zeus site is free to download to a 30-day trial version (in fact, the difference between the cracked version is just the authorization file). For instructions, see
[3] about the choice of how PHP works

The

Windows host needs to have a full version of PHP installed and cannot be installed using the Setup program provided by Php.net, but should be installed manually. If you need to use Unicode (UTF-8) encoding, under Windows host if the php4.3.x version needs to load the Iconv () function library separately (need to set extension_dir correctly in php.ini, such as Extension_dir = "C :/php/extensions/"
, you need to cancel at the same time, extension=php_iconv.dll the front of the line, and copy the C:/php/dlls/iconv.dll to the C:/windows/system32 directory.
Note: The php5.x version does not need and cannot be set up, and the LINUX/FREEBSD host needs to add Iconv parameters (./configure--with-iconv) when compiling PHP.
under Windows, if you use IIS, it is recommended that you run it in ISAPI mode and never use CGI. You can also use the FastCGI method (need to download fastcgi module and make a lot of configuration), this performance is better, if the use of two accelerators (Zend Optimizer, MMCache), test down incredibly can be used under FreeBSD Zend Performance Suite effect, but I test stability is poor, when the thread exceeds fastcgi limit of the maximum concurrent threads, some time it may cause the fastcgi process to die, and thus can not access any site, only restart the server to resolve. Under
Linux/freebsd, if you use Apache as a web Server, it is recommended to run PHP as an Apache module. If you use Zeus as a Web Server, you need to use fastcgi mode to run PHP, but fastcgi there may be a problem with the dead process, in the stop Zeus, sometimes can not stop the success, so that pidfile can not be cleared, the next time you start, FastCGI will not start. If you encounter bad gateway errors, you need to check if Pidfile is cleared, and if not, manually clear and restart Zeus. The best way to do this is to use crontab to automatically restart the fastcgi at regular intervals.
about fastcgi, it is normal to run under some hosts, and there will be no problem for several months. And some hosts are more frequent, whether it is windows or LINUX/FREEBSD, see luck.

[4] About PHP free accelerator selection

Free accelerators that can be used include Zend Optimizer, Turck mmcache, 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 is important to note that the latest version of PHP is 4.3.9/5.0.2, so if you need to use Turck MMCache in the latest version of PHP, you need to compile separately. I uploaded a compiled Turck mmcache v2.4.7 CVS for PHP v4.3.9 and Turck mmcache v2.4.7 CVS for PHP v5.0.2 two versions needed for the file, install MMCache 2.4 first. 6, then rename the files I provided in the archive to Mmcache.dll, replace the old file, note: These two files only apply to the Windows host, if you need to use under LINUX/FREEBSD, you need to compile MMCache separately.
However, it is necessary to note that the MMCache for PHP5.0.2 version, in PHP 5.0.2 use the existence of a bug, it is recommended to temporarily do not use MMCache under PHP5.0.2.
(3) Ioncube PHP Accelerator (PHPA)
Official site
Latest version 1.3.3R2 builds for PHP 4.3.0
This software can only be used under Solaris/freebsd/linux, does not support windows, and does not support the latest version of PHP. The Zend Optimizer, Turck mmcache Support various versions of the server (WINDOWS/LINUX/FREEBSD), various Web server (Iis/apache/zeus), and PHP. So I don't recommend using this software.
[5] About PHP charging accelerator selection

The available charge accelerators are Zend Winenabler, Zend performance Suite.
(1) Zend Winenabler
Official site
For some reason, Zend official recently suddenly all the pages related to this software has been deleted, the software is not sold anymore? This is Zend Performance suite under the Windows version, using the fastcgi way to run PHP, it is estimated that stability is not guaranteed.
(2) Zend performance Suite
Official site
Latest Version 4.0
This software can only be used under LINUX/FREEBSD, support Apache and Zeus. The PHP program is said to be up to 20 times times faster, but priced more expensive, starting at $1875. Web surface can be downloaded to cracked version, but 3.6.0/3.5.0 version, not support PHP 5.0. The features of Zend accelerator and the early Zend cache are included in this suite. Note: If you use this software to cache PHP programs, any modifications to the files require that the Web server be re-established to take effect.
[6] about MySQL installation

It is recommended to install the MySQL 4.0.x/4.1.x version, currently the latest version is 4.0.22/4.1.17. MySQL4.0 the above version can use query cache to significantly improve performance (need to set in My.ini). MySQL4.1 above uses new protocol, the speed increases more than 30%, the memory occupies less.
For the mysql4.1.x version, PHP 5. X provides a proprietary MYSQLI function extension to the mysql4.1.x version outside of the original MySQL extension, so that under mysql4.1.x, using the mysqli extension can increase SQL operations by up to dozens of times times faster than using the MySQL extension. The Ultimate Forum program comes with the MySQL extension, and we also offer the Ultimate forum mysqli extension Module sold separately, which you can choose to use.
For Windows hosts, you can install MYSQLD-NT, and you don't need to use mysqld-max-nt.
Note: If you are running MySQL 4.0.x under Windows, you will need to manually perform the following SQL operation on each data table to ensure that your database is stable without a data table error:

ALTER TABLE table_name Type=myisam;


Where table_name is the name of the data table.
For Linux hosts, you can install GLIBC, the current latest version 2.3.3, download the address and install the linuxthreads inside. can refer to
For the FreeBSD host, you can also install Linuxthreads, is the compilation of trouble.

The article is a bit more, but to develop the best PHP program, you must learn these optimization programs, so that you open the program will be more perfect you.

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.