微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Installing PHP APC on GNU/Linux Centos 5

               

原贴:http://2bits.com/articles/installing-PHP-apc-gnulinux-centos-5.html

      Published Mon, 2008/03/24 - 13:49, Updated Wed, 2009/07/15 - 23:40   

Complex PHP applications, such as Drupal, can gain a lot of performance benefits from running a PHP op-code cache/accelerators.

APC,
Alternate PHP Cache, is Now the most maintained free/open sourceop-code cache, and is being used more and more as it emerges to be the
most stable.

The instructions here detail how to get APC running on a CentOS 5server. The server happened to have Plesk on it as well, whichinitially made me hesitant to install APC "normally", since Plesk is sopicky on what other software is installed on the server. However, itseems to have worked out well.

First, we need the pecl command so we can download and install APC from the repositories.

Do to so, we execute the following command:

yum install PHP-pear

But, this will not run on its own, we need the following package for the PHPize command:

yum install PHP-devel

We also need the apxs command, which is installed via the following package:

yum install httpd-devel

Now we have all the software we need, so we install apc via the pecl command:

pecl install apc 

Once that finishes, we need to enable apc in Apache's configuration. the following command should do this for us.

echo "extension=apc.so" > /etc/PHP.d/apc.ini

Then we restart Apache:

/etc/init.d/httpd start

And we are all done. Watch for less execution time per page,and decreased memory usage per Apache process compared to what you had
before.

Links

You can find some additional tips at Setting up Alternative PHP Caching APC support on Centos server.

              ‹ Increasing Drupal's speed via the Squid caching reverse proxy                    up                    Installing PHP APC on GNU/Linux Ubuntu Gutsy Gibbon 7.10 (and Debian) ›          »

Pecl may not be able to perform the installation

Submitted by Joe (not verified) on Fri, 2008/11/21 - 00:05.

Dueto pecl following an 8 MB restriction that disregards PHP.ini, pecl maybomb out with a Fatal error if you attempt to install apc with it. Youcan solve this by using the command 'pear install pecl/acp' instead.

»

Got this working on Ubuntu 7.04 Feisty

Submitted by Volomike (not verified) on Sat, 2008/06/14 - 03:53.

I already had PEAR/PECL installed on a system with Apache2 and PHP5, running under Ubuntu 7.04 Feisty.


$ sudo su
# apt-get update
# apt-get install PHP5-dev
# apt-get install apache2-prefork-dev
# apt-get install apache-dev
# pecl install apc

answer yes when prompted


# echo "extension=apc.so" >> /etc/PHP5/apache2/PHP.ini
# /etc/init.d/apache2 stop
# apt-get remove apache2
# apt-get install apache2
# /etc/init.d/apache2 stop
# /etc/init.d/apache2 start
# exit
$

At least I hope this is working. I wish I knew how to test if the performance actually increased.

»

Trouble

Submitted by Sebastian Wikholm (not verified) on Thu, 2008/06/05 - 07:42.

Theinstalling with your instructions goes just fine, but APC doesnt wantto start for me. Apache / PHP gives the following error:

PHP Warning: PHP Startup: Unable to load dynamic library'/usr/lib/PHP/modules/apc.so' - /usr/lib/PHP/modules/apc.so: cannotopen shared object file: Permission denied in UnkNown on line 0

Any help would really be appreciated

»

Thanks, Khalid.I asked my

Submitted by venkat-rk (not verified) on Tue, 2008/03/25 - 09:57.

Thanks, Khalid.

I asked my host to do it for me and immediately from then onwards, all my drupal pages are showing an internal 500 server error.

Does APC have a problem with PHP running as suPHP (like suexec)?

Thanks,
Venkat

»

Doesn't work

Submitted by Khalid on Tue, 2008/03/25 - 10:44.

ActuallyI recall reading specifically that suexec is kNown not to work withAPC. Perhaps this is because it is CGI (new process every time arequest comes in). The only versions that work with APC and otheraccelerators are the mod_PHP (Apache) or Fast CGI.

In your case, suexec is a Trade off (security vs. performance).
--
2bits -- Drupal consulting

»

well, it seems to work:-)My

Submitted by venkat-rk (not verified) on Tue, 2008/03/25 - 10:55.

well, it seems to work:-)

My host had simply given incorrect permissions on the temporary APCscript. I don't kNow the intricacies of it, but they said setup wouldbe slightly different on a cPanel VPS and enabled it.

Venkat

»

suphp

Submitted by Khalid on Tue, 2008/03/25 - 11:20.

Thanks for the email.

Your site is running suPHP (which is still CGI), and suhosin which some say is incompatible with op-code caches (not sure).

Please try with and without APC using devel and see if the pages execute faster with APC on suPHP. I doubt they would.
--
2bits -- Drupal consulting

»

suggestion

Submitted by Drupal Theme Garden (not verified) on Tue, 2008/03/25 - 05:24.

Nice and simple tutorial.

One question:
Why APC, and not eAccelerator?
In some of your prevIoUs articles (benchmarking APC vs eAccelerator using drupal and PHP op code caches/accelerators: a must for a large site) you wrote that eAccelerator has better performance over APC.

»

Stability

Submitted by Khalid on Tue, 2008/03/25 - 10:50.

eAccelerator is definitely better than APC for speed (faster) and memory utilization (uses less memory).

However, with newer versions of PHP and Drupal, APC Now has the edgein stability. PrevIoUsly, we had maybe one or two seg faults witheAccelerator per week, which was acceptable, and the logwatcher scriptrestarted things automatically.

After upgrading, it was seg faulting every 2 hours. Once we switched to APC, it was stable and rock solid.

There is also xcache, which we experimented with, but not used in production work.

I plan to publish updated benchmarks of APC, eAccelerator and xcache in the near future.
--
2bits -- Drupal consulting

 

           

分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。