分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow
也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!
原贴:http://2bits.com/articles/installing-php-apc-gnulinux-centos-5.html
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.
Got this working on Ubuntu 7.04 Feisty
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
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
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
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
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
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
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
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
Pecl may not be able to perform the installation
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.