RSS
热门关键字:  php  lighttpd  找回密码  密码找回  client
当前位置 :| 主页>技术资料>Linux>

在Linux安装XCache PHP加速器

来源:phpsoho.com 作者: 时间:2008-08-08 Tag:linux   xcache   cache   点击:

XCache是选择,于著名eAccelerator和APC的快速和稳定的PHP加速器和opcode cacher (供选择的PHP贮藏所)是相似的。 XCache引伸工作在贮藏PHP的编写bytecode (opcode或中间代码)形式旁边在每个页面要求写电影脚本避免天花板解析和编写PHP原始代码和因而减少服务器装载,促进PHP剧本表现并且从2-10次增加PHP代码的速度。

XCache支持所有最新的PHP cvs分支例如PHP 4.3, PHP 4.4, PHP 5.1,并且PHP 5.2在Linux服务器包括共同性在cPanel使用,并且Plesk根据网络主持服务器的CentOS和ThreadSafe或窗口网络服务器。 XCache克服在opcachers或加速器存在例如无法与新的PHP版本一起使用的很多问题。 在旁边,也是的XCache 基准点是更加快速的 比其他opcode cachers。

这是一个简单的讲解和指南关于怎样通过手工编写安装XCache PHP cacher从原始代码包裹。 如果您使用Wordpress或使用XCache加速和改进Wordpress blog表现,您应该首先保证PHP被升级到最新的版本(PHP 5.2.1),因为PHP 4也许导致某个不稳定问题例如无法张贴评论、部分页装货和等。 无论如何,总推荐PHP5,如果可能。 并且和与所有PHP加速器, XCache不会与PHP suEXEC一起使用打开。 PHP suEXEC一定是残疾为了XCache能适当地运作。

当前, XCache维护2个分支,即。 版本1.0.3和版本1.2.0。 版本现在是稳定的为PHP的多数版本1.2.x推荐的发行,当版本1.0.x为PHP 4.3.x和4.4.x被推荐和版本包括5.1.x和5.2.x,除了PHP 5.0.x系列。 如果您使用PHP4,尝试两采摘那个的XCache的版本最适当为您的应用。 要检查您是usinng PHP的哪个版本,发布命令php - v或设定一个PHP文件与以下内容,然后叫文件从浏览器:

<?php
phpinfo ();
?>

  1. 变成用户地方源目录例如/usr/local/src通过使用跟随命令:

    CD的/usr/local/src

  2. 检索并且下载XCache的版本的来源包裹您选择对设施。

    wget http://210.51.190.228/pub/XCache/Releases/xcache-1.0.3.tar.gz (为XCache 1.0.3)

    wget http://210.51.190.228/pub/XCache/Releases/xcache-1.2.0.tar.gz (为XCache 1.2.0)

  3. Untar,拉开,打开或者提取档案拉链以以下命令之一:

    沥青- zxf xcache-*.tar.gz
    gzip - dc xcache-*.tar.gz | 沥青- x

  4. 进入xcache目录与来源内容:

    cd xcache

  5. Trigger PHP building environment:

    phpize

  6. Optional but recommended practice is to build XCache outside of source directory:

    mkdir ../xcache-build
    cd ../xcache-build

  7. Run the configure with the option that you want, the basic is as below which will enable the XCache by default:

    ../xcache/configure –enable-xcache

    You can list out all available options by using ../xcache/configure –help command, which will display the following:

    –enable-xcache Include XCACHE support.
    –enable-xcache-optimizer XCACHE: (N/A)
    –enable-xcache-coverager XCACHE: Enable code coverage dumper
    –enable-xcache-assembler XCACHE: (N/A)
    –enable-xcache-disassembler XCACHE: Enable opcode to php variable dumper
    –enable-xcache-encoder XCACHE: (N/A)
    –enable-xcache-decoder XCACHE: (N/A)
    –enable-xcache-test XCACHE: Enable self test - FOR DEVELOPERS ONLY!!

  8. Compile the source with following command:

    make

    Ensure that no error occurred.

  9. If you haven’t already using root account, su to root user.
  10. Install XCache binary with the following command:

    make install

    Ensure that no error occurred, and note down the extension installation path of the xcache.so.

  11. Next, XCache need to be configured and enabled in PHP.INI file. Locate the correct location of php.ini configuration file by using phpinfo() function (see sample listed above to check version of PHP). In web hosting environment, normally it’s located in /etc or /usr/local/lib. If the install of PHP parses the /etc/php.d/ folder, then simply create a file in that folder named “xcache.ini” or copy over the sample xcache.ini came with source package.

    Change back to xcache source unpack directory, and run the following command with root user:

    cat xcache.ini >> /etc/php.ini
    $EDITOR /etc/php.ini

    Note: change to the path of php.ini accordingly

    This will append the default XCache configuration to the end of php.ini. Alternatively, you can copy and paste the following text into the php.ini file yourself too:


    [xcache-common]
    ;; install as zend extension (recommended)
    zend_extension = /usr/local/lib/php/extensions/no-debug-non-zts-xxx/xcache.so
    ;; install as zend extension with thread-safe
    ; zend_extension_ts = /usr/local/lib/php/extensions/non-debug-zts-xxx/xcache.so
    ;; install as PHP extension (extension_dir must be set to the full path to xcache.so)
    ; extension = xcache.so

    [xcache.admin]
    xcache.admin.user = “admin”
    xcache.admin.pass = md5($your_password)

    [xcache]
    xcache.shm_scheme = “mmap”
    xcache.size = 16M
    xcache.count = 1
    xcache.slots = 8K
    xcache.ttl = 0
    xcache.gc_interval = 0

    xcache.var_size = 0M
    xcache.var_count = 1
    xcache.var_slots = 8K
    xcache.var_ttl = 0
    xcache.var_maxttl = 0
    xcache.var_gc_interval = 300

    xcache.test = Off
    xcache.readonly_protection = Off
    xcache.mmap_path = “/dev/zero”
    xcache.coredump_directory = “”
    xcache.cacher = On
    xcache.stat = On
    xcache.optimizer = Off

    [xcache.coverager]
    xcache.coverager = Off
    xcache.coveragedump_directory = “”

  12. You can configure XCache to your preference. One setting that must be changed is under the [xcache-common], where you must specify the correct installation path of the XCache extension module. You can also opt to run XCache as PHP extension instead of extension for Zend module. In this case, comment and uncomment the line accordingly. Other important options include “xcache.size” which specify amount the memory allocated to XCache, “xcache.count” to take advantage of multi-core processors or multiple processors. And if you plan to use XCache web administration interface, input the “xcache.admin.user” and md5 checksum value of “xcache.admin.pass”. Try MD5 tools to generate the correct value, or use the following command to generate the MD5 for your password:

    echo -n “password” | md5sum

    Note: Explanation and definition of all XCache INI settings can be found here.

  13. Restart the Apache httpd web server. The following commands should work:

    /etc/init.d/apache* restart

    or

    /etc/init.d/httpd* restart

  14. Ensure the XCache is running by calling PHP file with phpinfo() (see sample above). You should see a new XCache Support block with opcode cache enabled.
  15. If you wish to set up XCache administration page, configure an alias in httpd.conf of Apache to point to the admin subdirectory within XCache. To do so, add the following line to httpd.conf (assuming your xcache source is extracted at /usr/local/src/, and you want to access admin page from /xcache-admin/ URL):

    Alias /xcache-admin/ /usr/local/src/xcache/admin/

    Then restart Apache web server. For lighttpd, add the following line instead:

    alias.url += (”/xcache-admin/” => “/usr/share/xcache/admin/”)

    Alternatively, you can also copy the whole “admin” directory from the “xcache” source folder to web document-root or sub-directory of your domain which is web accessible. However, this method is not recommended as you may forget to update the admin page when XCache package is updated.

    Note: Ensure that open_basedir protection, if enabled, is excluded for the directory contains admin-page.

IMPORTANT: You're reading a machine translated page which is provided "as is" without warranty. Unlike human translation, machine translation does not understand the grammar, semantics, syntax, idioms of natural language, thus often produce inaccurate and low quality text which is misleading and incomprehensible. Thus, please refer to original English article whenever possible.


最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册