您的位置:首页 > 其它

magento -- 给服务器安装APC提升服务器的性能容量

2009-09-21 21:51 281 查看
欢迎转载,请注明来源:blog.csdn.net/xinhaozheng

magento的性能,我在这上面不知道花了多少时间.已经试过了eaccelerator,非常不错.也来试试APC.因为据说它比较稳定.不管什么说要试试看,只要有利于提高速度的.

说明:APC,全称是Alternative PHP Cache (APC),是一个开源的PHP缓存扩展模块.它的目的是为PHP编译字节码的缓存和代码优化提供一个免费开源而又稳定的框架.

安装apc

前提:

没有要求或依赖于其它的任意模块

安装步骤

安装APC 有很多方法,不过推荐使用pecl.它和pear一样,非常好用,甚至好些选项,命令都是一样的.

#cd /usr/local/php/bin

# ./pecl install apc

如果有碰到问题请参考:ear.php.net is using a unsupported protocal

[root@LSN-D3092 bin]# ./pecl install apc
pecl.php.net is using a unsupported protocal - This should never happen.


# cd /usr/local/php/lib/php/.channels

#rm pear.php.net.reg

# rm pecl.php.net.reg

#cd /usr/local/php/bin

# ./pecl updae-channels

Updating channel "doc.php.net"

Channel "doc.php.net" is up to date

Updating channel "pear.php.net"

Update of Channel "pear.php.net" succeeded

Updating channel "pecl.php.net"

Channel "pecl.php.net" is up to date

# ./pecl install apc

Sorry, I was not able to successfully run APXS. Possible reasons:

1. Perl is not installed;

2. Apache was not compiled with DSO support (--enable-module=so);

3. 'apxs' is not in your path. Try to use --with-apxs=/path/to/apxs

The output of apxs follows

/tmp/pear/temp/APC/configure: line 3439: apxs: command not found

configure: error: Aborting

ERROR: `/tmp/pear/temp/APC/configure --with-apxs' failed

我是安装了perl,而且在编译安装apache时也必然启用了 --enable-so,所以判断是第三种情况,编译程序找不到apxs,在当前的查找路径找不到,解决方法,简单的你可以在bin目录给apxs创建一个软件链接,如

ln -s /usr/local/apache2/bin/apxs /bin/apxs

不过再次运行命令安装时我发现可以直接在它停下来询问时指定apxs的路径:

[root@LSN-D3092 bin]# ./pecl install apc

downloading APC-3.0.19.tar ...

Starting to download APC-3.0.19.tar (Unknown size)

.....................done: 564,736 bytes

47 source files, building

WARNING: php_bin /usr/local/php/bin/php appears to have a suffix /bin/php, but config variable php_suffix does not match

running: phpize

Configuring for:

PHP Api Version: 20041225

Zend Module Api No: 20060613

Zend Extension Api No: 220060519

Use apxs to set compile flags (if using APC with Apache)? [yes] :n(注意我用n)

...........

The output of /var/tmp/pear-build-root/APC-3.0.19/n follows

/tmp/pear/temp/APC/configure: line 3439: /var/tmp/pear-build-root/APC-3.0.19/n: No such file or directory

configure: error: Aborting

ERROR: `/tmp/pear/temp/APC/configure --with-apxs=n' failed (这行错误提示说明我们可以直接指定)

所以再来一次:

[root@LSN-D3092 bin]# ./pecl install apc

downloading APC-3.0.19.tar ...

Starting to download APC-3.0.19.tar (Unknown size)

.....................done: 564,736 bytes

47 source files, building

WARNING: php_bin /usr/local/php/bin/php appears to have a suffix /bin/php, but config variable php_suffix does not match

running: phpize

Configuring for:

PHP Api Version: 20041225

Zend Module Api No: 20060613

Zend Extension Api No: 220060519

Use apxs to set compile flags (if using APC with Apache)? [yes] :/usr/local/apache2/bin/apxs

(cd .libs
&& rm -f apc.la && ln -s ../apc.la apc.la)
/bin/sh /var/tmp/pear-build-root/APC-3.0.19/libtool --mode=install cp
./apc.la /var/tmp/pear-build-root/APC-3.0.19/modules
cp ./.libs/apc.so /var/tmp/pear-build-root/APC-3.0.19/modules/apc.so
cp ./.libs/apc.lai /var/tmp/pear-build-root/APC-3.0.19/modules/apc.la
PATH="$PATH:/sbin" ldconfig -n
/var/tmp/pear-build-root/APC-3.0.19/modules
----------------------------------------------------------------------
Libraries have been installed in:
/var/tmp/pear-build-root/APC-3.0.19/modules
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following: - add LIBDIR
to the `LD_LIBRARY_PATH' environment variable during execution - add
LIBDIR to the `LD_RUN_PATH' environment variable during linking - use
the `-Wl,--rpath -Wl,LIBDIR' linker flag - have your system
administrator add LIBDIR to `/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
Build complete.
Don't forget to run 'make test'.
running: make
INSTALL_ROOT="/var/tmp/pear-build-root/install-APC-3.0.19" install
Installing shared extensions:
/var/tmp/pear-build-root/install-APC-3.0.19/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/
running:
find "/var/tmp/pear-build-root/install-APC-3.0.19" | xargs ls -dils
64192518 4 drwxr-xr-x 3 root root 4096 Sep 21 12:57
/var/tmp/pear-build-root/install-APC-3.0.19
64192577 4 drwxr-xr-x 3 root root 4096 Sep 21 12:57
/var/tmp/pear-build-root/install-APC-3.0.19/usr
64192578 4 drwxr-xr-x 3 root root 4096 Sep 21 12:57
/var/tmp/pear-build-root/install-APC-3.0.19/usr/local
64192579 4 drwxr-xr-x 3 root root 4096 Sep 21 12:57
/var/tmp/pear-build-root/install-APC-3.0.19/usr/local/php
64192580 4 drwxr-xr-x 3 root root 4096 Sep 21 12:57
/var/tmp/pear-build-root/install-APC-3.0.19/usr/local/php/lib
64192581 4 drwxr-xr-x 3 root root 4096 Sep 21 12:57
/var/tmp/pear-build-root/install-APC-3.0.19/usr/local/php/lib/php
64192582 4 drwxr-xr-x 3 root root 4096 Sep 21 12:57
/var/tmp/pear-build-root/install-APC-3.0.19/usr/local/php/lib/php/extensions
64192583
4 drwxr-xr-x 2 root root 4096 Sep 21 12:57
/var/tmp/pear-build-root/install-APC-3.0.19/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613
64192576
468 -rwxr-xr-x 1 root root 472613 Sep 21 12:57
/var/tmp/pear-build-root/install-APC-3.0.19/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/apc.so
Build
process completed successfully
Installing
'/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/apc.so'
install ok: channel://pecl.php.net/APC-3.0.19
configuration option "php_ini" is not set to php.ini location
You should add "extension=apc.so" to php.ini


这样apc就被编译成一个so扩展,不过你需要修改php配置文件来加载,同时要设置相应的参数.首先呢,把这行加过去,

extension=apc.so

然后你可以在 php.ini中添加一个APC section

[APC] //这个名称可以随意的

apc.enabled
= "1"

apc.shm_size=256

apc.num_files_hint=10000

apc.user_entries_hint=10000

apc.max_file_size=5M

再进一步, 在magento的app/etc/local.xml中添加如下配置(欢迎转载,请注明来源:blog.csdn.net/xinhaozheng
)



<global>
<cache>
<backend>apc</backend>
<prefix>MAGE_</prefix>
</cache>
</global>


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: