How to speed up your PHP program

Source: Internet
Author: User
Program

I've always thought PHP was a very fast running speed, especially after the Zend engine accelerated. But PHP still has the possibility of acceleration, you know?

Everything starts with how to optimize PHP's compilation

Attempt to use a special compilation parameter for the CPU model-msse-mmmx-mfpmath=sse

Add-03 parameter at compile time

Adjust CPU parameters When compiling-MARCH-MCPU use Caution

Try to compile only the modules you need to avoid unwanted extended loading

For the less-used extension module, it should be compiled into a shared mode to facilitate dynamic loading at run time.

Maybe sometimes--disable-all will be your best friend.

PHP statically compiled to Apache can speed up 20%

# PHP

./configure--with-apache=/path/to/apache_source

# Apache

./configure--activate-module=src/modules/php4/libphp4.a

Optimize your PHP configuration file

Confirm that your register_globals configuration is disabled

Disable magic_quotes_* option

Close expose_php

Close REGISTER_ARGC_ARGV

Do not enable always_populate_raw_post_data unless absolutely necessary

Optimal configuration of Apache server

Maxspareservers with high configuration

MaxClients set to 2/5 that your server can withstand

The ideal situation for Maxrequestsperchild is 0 (not limited), but is actually set to a more than one value

Optimizing File Access

DirectoryIndex file list as short as possible

In any case prohibit the allowoverridenone of the. htaccess file

Using FollowSymLinks to simplify file access processing

Avoid using mod_rewrite or more complex operations

Disable if the log is not necessary

If you must use a log, record it in a file and clear it after parsing

Eliminate expensive system calls

Don't open extendedstatus.

Use IP instead of domain name when you allow and disallow rules

Do not enable hostnamelookups

Keep Serversignature off

Set KeepAlive to a smaller value

Dynamic and static content separation

Improve hard Drive performance parameters

Use output_buffering to optimize the interaction between PHP and Apache

Increase the sendbuffersize size of Apache

Improve cache execution

Using the PHP code caching mechanism

Turck MMCache Stop developing

APC is slow and not optimized

Zend Cache optimization performance is good, but pay

Ioncube PHP Accelerator free but not open source

If you can use zlib compression

Reduce output data

Replace HTML with CSS

Compress HTML pages

Using Sessions Management

Optimize your SQL command







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.