介绍几种PHP站点性能的优化方法
如果能够合理运用
1:object code缓存
每次发生一个请求的时候,都需要把你对象代码重新编译一遍,如果你使用了缓存,那么就避免了重新编译,这样可以使得你的脚本执行得更快,提高PHP站点性能。
有以下的包可以使用:
A) Ioncube:http://www.ioncube.com/
B) Zend Encoder: http://www.zend.com/products/zend_safeguard
C) Turckl MMCache: http://freshmeat.net/projects/turck-mmcache/
2:模板系统
模板系统提供了另外一种不同的缓存形式。内容缓存。当你有很多静态数据和很多页面不需要reload的时候,模板系统是很有帮助的。缓存系统也将code和html分开,不仅使得代码的执行时间改善,也让你将来的维护变得容易,提高了PHP站点性能。
A) Smarty Templates: http://smarty.PHP.net/
B) Pear Templates: http://pear.PHP.net/package/html_template_it/redirected
C) PHP savant: http://PHPsavant.com/yawiki/
3:分布式对象缓存系统
使用得最普遍的是memcached
这种系统把数据库数据放在一个很大的内存池里,这样使得你的网站跑得很快,实现了PHP站点性能的优化。
4:设置一些PHP变量
variables_order = ‘GPC’
register_argc_argv = ‘Off’
register_globals = ‘Off’
always_populate_raw_post_data = ‘Off’
magic_quotes_gpc = ‘Off’
5: Output Compression
几乎所有的浏览器都支持Gzip的压缩方式,gzip可以降低80%的输出,付出的代价是大概增加了10%的cpu计算量。但是赚到的是不仅占用的带宽减少了,而且你的页面加载会变得很快,优化了你的PHP站点性能。
你可以在PHP.ini中开启它
zlib.output_compression = On
zlib.output_compression_level = (level)(level可能是1-9之间的数字,你可以设置不同的数字使得他适合你的站点。)
如果你使用apache,你也可以激活mod_gzip模块,他是高度可定制的。
6:其他
当你使用数据库的时候,只取那些你需要使用的数据,避免使用select * from mytable这样的句子。
另外使用索引也是对PHP站点性能的优化很有帮助的。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Atom editor mac version download
The most popular open source editor
