How install apcu as php7 extension on debian

2019-04-04 10:25发布

问题:

I have seen this tutorial for ubuntu. http://thereluctantdeveloper.com/2015/12/quick-and-dirty-php-70-set-up-on-ubuntu-1404-with-apcu

It's not clear for me after step(git clone). I need apcu extension for my app to perform faster. Please guide to install apcu extension for php 7 on debian.

回答1:

First, I'm assuming you installed PHP7 using the DotDeb APT Repository. If not, this is how you should install it.

Once PHP7 is installed and working properly, and assuming there are no other versions of PHP installed on the system, install apcu via:

sudo apt-get install php7.0-dev
pecl channel-update pecl.php.net
pecl install apcu

echo "extension=apcu.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`

Just press enter if prompted to specify any configuration.



回答2:

Run :

sudo apt-get install php7.0-dev
pecl channel-update pecl.php.net
pecl install apcu

Do not immediately add extension=apcu.so on php.ini without checking. extension=apcu.so should automatically get added on /etc/php/7.0/cli/conf.d/20-apcu.ini. You can run php -i | grep app to check or cat /etc/php/7.0/cli/conf.d/20-apcu.ini. If you load twice, you'll get :

PHP Warning:  Module 'apcu' already loaded in Unknown on line 0

This message is probably kept for older system :

install ok: channel://pecl.php.net/apcu-5.1.5
configuration option "php_ini" is not set to php.ini location
You should add "extension=apcu.so" to php.ini

I can not comment on the existing answer (point is less than 50). I got that PHP error, then found that file.



回答3:

I know that this post is old but I would like to contrib with the way that works for me, because I tried the three answers in this question and I couldn't install APCU successfully. My problem with the answers wasn't the installation of APCU, pecl install apcu works and installed it. But I try to add the extension line in php.ini following each method, but neither of them works for me. I checked in a php file with phpinfo() and it always didn't show the APCU as installed extension.

After research more in the search results I found a easy way to install it in WPBullet. What I did was to install the packages php-apcu and php-apcu-bc with:

sudo apt-get install php7.0-apcu

This works for me without manual writting in php.ini. Don't forget to restart apache2, or whatever you have as server.



回答4:

Just installed APCu on a Ubuntu 14.04.3 LTS with PHP 7.0.3-2:

$ pecl install apcu
$  cat > /etc/php/mods-available/test.ini
; configuration for php apcu module
; priority=20
extension=apcu.so
$ ln -s /etc/php/mods-available/apcu.ini /etc/php/7.0/fpm/conf.d/20-apcu.ini
$ service php7.0-fpm restart

phpinfo() output:



回答5:

Check /etc/php/(version like 7.2)/cli/conf.d directory and find 20-apcu.ini. If you dont see it there, You need to install it. To install follow bellow command:

sudo apt-get install php7.2-apcu

Now add bellow line in php.ini file if it is not there.

extension=apcu.so

Notice: for php7.2-apcu use your own php version. for example php7.0-apcu

After install restart your php7.X-fpm service if you are using nginx

sudo service php7.2-fpm restart

Now reload nginx

sudo service nginx reload

or reload apache, if you are using it:

sudo service apache2 reload


标签: debian apc php-7