search
HomeBackend DevelopmentPHP Tutorial网站加速 PHP 缓冲的免费实现方法_PHP

我们知道 Zend 有免费的优化引擎针对 PHP 而作,但是 FreeLAMP 这次采用的是一个叫做 PHP Accelerator 的缓冲产品。

  我们在 “LAMP 加速” 这篇文章中阐述过加速的几种办法,其中提到了 PHP Accelerator,它的安装方法十分简单,但是需要去他的网站获取一个激活键。

language="JavaScript1.1" src="http://img.bitscn.com/upimg/allimg/070123/1836470.jpg" />

  一、下载:

  www.php-accelerator.co.uk/download.php

  二、获取激活键并安装:

  www.php-accelerator.co.uk/activate.php

  注册自己的 SERVER_NAME 后,你会得到下面的提示:

  Your key for www.freelamp.com is 8edfd13946c96309244fcca309415902

  Now you must set the key for www.freelamp.com in your site configuration.

  For single domains not using virtual hosts

  The key can be set in the php.ini file as follows:

  # PHPA key for www.freelamp.com

  #

  phpa.registration_key = 8edfd13946c96309244fcca309415902

  For domains setup as a virtual host

  Add the key to the domain specific section for your web server.

  # www.freelamp.com VHost entry

  #

  

  ServerName www.freelamp.com

  # ... (other vhost specific config)

  # php settings

  php_value phpa.registration_key 8edfd13946c96309244fcca309415902

  # also enable phpa if set to off in the php.ini (the default is on)

  php_value phpa 1

  

  具体的 phpa 值的设置,可以参考软件随带的 CONFIGURATION 文件的配置。

  由于大多数网站是虚拟主机配置,所以,建议采用 php_value phpa. 的方式设置。

  例如:

  php_value phpa.tweaks off

  php_value phpa.cache_dir /tmp

  php_value phpa.file_perms 400

  php_value phpa.ignore_files "/index.php, /a/test.php"

  # php_value phpa.ignore_dirs "/data/WWW/site1/,/cache/"

  php_value phpa.shm_size 8

  php_value phpa.shm_key 0xc0deb00

  php_value phpa.shm_perms 664

  三、设置 php.ini

  假设我们把下载后的文件解开到 /usr/local/php ,那么在 php.ini 中加入:

  zend_extension=/usr/local/php/php_accelerator_1.2p2.so

  并注释掉原来的 Zend 优化引擎:

  # zend_extension=/usr/local/Zend/lib/ZendOptimizer.so

  重新启动 Apache ,用浏览器浏览一个任意 PHP 页面可以看到 /tmp 下面生成了一些 phpa 开头的文件。另外一个检查缓冲是否起作用的办法是看 phpinfo() 的输出,原来的 Zend 优化引擎的说明部分,已经被显示成:

  This program makes use of the Zend Scripting Language Engine:

  Zend Engine v1.1.1, Copyright © 1998-2001 Zend Technologies

  with the PHP Accelerator v1.2p2, Copyright © 2001-2002, by Nick Lindridge

  需要说明的是,安装 INSTALL 安装说明上的办法,其中的 .so 文件和真实的 .so 文件有差异,所以,你在安装的时候需要注意到这个区别。

  四、调整缓冲大小

  PHP Accelerator 提供了缓冲管理命令:

  phpa_cache_admin -mv 观察内存的缓冲情况

  phpa_cache_admin -fv 观察文件的缓冲情况

  phpa_cache_admin -k 设置缓冲大小

  五、总结

  该软件提供的 INSTALL 文件阐述了关于性能上的一些说法,笔者不在这里赘述。

  需要说明的是,FreeLAMP.com 的文章目前不是 PHP 架构的,但是论坛系统是 PHP 架构的,所以性能上的提升只会是论坛系统的提升。

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
How does PHP identify a user's session?How does PHP identify a user's session?May 01, 2025 am 12:23 AM

PHPidentifiesauser'ssessionusingsessioncookiesandsessionIDs.1)Whensession_start()iscalled,PHPgeneratesauniquesessionIDstoredinacookienamedPHPSESSIDontheuser'sbrowser.2)ThisIDallowsPHPtoretrievesessiondatafromtheserver.

What are some best practices for securing PHP sessions?What are some best practices for securing PHP sessions?May 01, 2025 am 12:22 AM

The security of PHP sessions can be achieved through the following measures: 1. Use session_regenerate_id() to regenerate the session ID when the user logs in or is an important operation. 2. Encrypt the transmission session ID through the HTTPS protocol. 3. Use session_save_path() to specify the secure directory to store session data and set permissions correctly.

Where are PHP session files stored by default?Where are PHP session files stored by default?May 01, 2025 am 12:15 AM

PHPsessionfilesarestoredinthedirectoryspecifiedbysession.save_path,typically/tmponUnix-likesystemsorC:\Windows\TemponWindows.Tocustomizethis:1)Usesession_save_path()tosetacustomdirectory,ensuringit'swritable;2)Verifythecustomdirectoryexistsandiswrita

How do you retrieve data from a PHP session?How do you retrieve data from a PHP session?May 01, 2025 am 12:11 AM

ToretrievedatafromaPHPsession,startthesessionwithsession_start()andaccessvariablesinthe$_SESSIONarray.Forexample:1)Startthesession:session_start().2)Retrievedata:$username=$_SESSION['username'];echo"Welcome,".$username;.Sessionsareserver-si

How can you use sessions to implement a shopping cart?How can you use sessions to implement a shopping cart?May 01, 2025 am 12:10 AM

The steps to build an efficient shopping cart system using sessions include: 1) Understand the definition and function of the session. The session is a server-side storage mechanism used to maintain user status across requests; 2) Implement basic session management, such as adding products to the shopping cart; 3) Expand to advanced usage, supporting product quantity management and deletion; 4) Optimize performance and security, by persisting session data and using secure session identifiers.

How do you create and use an interface in PHP?How do you create and use an interface in PHP?Apr 30, 2025 pm 03:40 PM

The article explains how to create, implement, and use interfaces in PHP, focusing on their benefits for code organization and maintainability.

What is the difference between crypt() and password_hash()?What is the difference between crypt() and password_hash()?Apr 30, 2025 pm 03:39 PM

The article discusses the differences between crypt() and password_hash() in PHP for password hashing, focusing on their implementation, security, and suitability for modern web applications.

How can you prevent Cross-Site Scripting (XSS) in PHP?How can you prevent Cross-Site Scripting (XSS) in PHP?Apr 30, 2025 pm 03:38 PM

Article discusses preventing Cross-Site Scripting (XSS) in PHP through input validation, output encoding, and using tools like OWASP ESAPI and HTML Purifier.

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

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

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

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.

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.