No package php-opcache available - php

I found so many questions here but whatever i try i always get the msg
No package php-opcache available
i tried to follow this
http://www.unixmen.com/install-remi-repository-rhel-centos-scientific-linux-76-x5-x-fedora-201918/
then install opcache
# yum install php-opcache
but still no luck
PS: i have WHM/Cpanel installed on my AWS server and i need to install opcache for Magento
i have PHP version 5.5
PHP 5.5.35 (cgi-fcgi) (built: May 16 2016 18:26:28)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
i tried to enable it from php.ini but it says opcache.so not found
any help would be appreciated
Failed loading /usr/local/lib/php/extensions/no-debug-non-zts-20121212/opcache.so: /usr/local/lib/php/extensions/no-debug-non-zts-20121212/opcache.so: cannot open shared object file: No such file or directory

If you're installing from Remi's repo, the name will be php55-php-opcache, which you could have determined from running yum search opcache.
But your error refers to /usr/local/lib/php/extensions/no-debug-non-zts-20121212/opcache.so which tells me that you have a version of PHP that was compiled from source. You need to either use packages or compile from source, not both. If you install from a package, things will not be put into /usr/local/.

Related

How To Enable SoapClient in PHP 7.3 Ubuntu Ubuntu 16.04.7 LTS Xenial

Im using PHP 7.3 16.04.7 LTS Xenial, and I cant enable the module SoapClient in my phpinfo().
I already remove the ";" in my php.ini configuration and restart the apache2 to enable the soap module.
The next thing I was recomended doing was to install the php package with
When I run:
sudo apt install php7.0-soap
I get
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
php7.0-soap : Depends: php7.0-common (= 7.0.33-0ubuntu0.16.04.16) but 7.0.33-20+ubuntu16.04.1+deb.sury.org+1 is to be installed
E: Unable to correct problems, you have held broken packages.
When I check for held packages with:
dpkg --get-selections | grep hold
I get nothing.
When i run:
php -v
I get:
PHP 7.3.16-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Mar 20 2020 13:51:21) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.16, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.16-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
How can I get out of this broken state where I cant install what I need, and I cant solve held broken packages?

Install xdebug on specific php version

I'm trying to install xdebug.
I've already seen some issues about it (like this one : Installing xdebug with PHP 5.5 ) but it seems outdated and not corresponding to my issue).
When I try
sudo pecl install xdebug
I'm getting the following error
WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
downloading xdebug-2.8.0.tgz ...
Starting to download xdebug-2.8.0.tgz (238,122 bytes)
.................................................done: 238,122 bytes
69 source files, building
running: phpize
sh: 1: phpize: not found
ERROR: `phpize' failed
It seems that means phpize isn't installed in my php version
php -v
PHP 7.2.24-0ubuntu0.19.04.1 (cli) (built: Oct 24 2019 11:49:39) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.24-0ubuntu0.19.04.1, Copyright (c) 1999-2018, by Zend Technologies
So, some topics seems to tell me to change my php version to download a version with phpsize included. But I was more looking for a way to add phpsize to my current php version but I don't know how to do that.
Thanks for your assistance
If Ubuntu first you need install php dev version:
sudo apt install php7.x-dev
And then:
sudo pecl install xdebug
I had some problems with xdebug version too.
I had to install an specific version for php7.1 using PECL,
I don't really know if your question is already solved but let me share you this webpage, it's the compatibility graph to know wich version works with an specific php versions:
https://xdebug.org/docs/compat
As far as I know if you want to install the latest xdebug version you can use the repo, but if you need an old version you'll be forced to install it using PECL.
Hope you find this answer usefull!

Why is php zip extension not working on ubuntu though it's installed?

I'm on Ubuntu 16.04 and I'm trying to install prestashop e-commerce CMS that requires php zip extension to unzip the main CMS folder.
I have installed php-zip and php7.2-zip and I also restarted the web server (apache2) but the CMS still displays the following message
An error has occured:
You must install PHP zip extension first
Here's the result of my installed php zip packages and my current php version:
eljaouhari#eljaouhari-HP-350-G1:/var/www/html$ php -v
PHP 7.2.5-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: May 5 2018 04:59:13) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.5-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
eljaouhari#eljaouhari-HP-350-G1:/var/www/html$ apt list --installed | grep php | grep zip
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
php-zip/xenial,xenial,now 1:7.2+60+ubuntu16.04.1+deb.sury.org+1 all [installé]
php7.2-zip/xenial,now 7.2.5-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installé]
I spent an hour and a half trying to figure out whether I need to activate the extestion on the php.ini file and also installing and reinstalling and restarting the web server but nothing seems to work.
I have tried a few solutions on the web that used to work for me but I can't seem to find a good solution.
Please help me with your experience!
I've found the solution after I printed the results of the phpinfo() function.
It seems that the version of php printed with the "php -v" command is not the version that actually apache is using. Apache ended up using the 7.0 version.
Thanks everyone.

Installing phpredis on Ubuntu 14.04 for PHP 7.1

My php -v
PHP 7.1.15-1+ubuntu14.04.1+deb.sury.org+2 (cli) (built: Mar 6 2018
11:51:39) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine
v3.1.0, Copyright (c) 1998-2018 Zend Technologies
with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans
with Zend OPcache v7.1.15-1+ubuntu14.04.1+deb.sury.org+2, Copyright (c) 1999-2018, by Zend Technologies
I have tried both the pecl way
sudo pecl install redis
sudo service php7.1-fpm restart
And the manual way from https://github.com/phpredis/phpredis
phpize
./configure [--enable-redis-igbinary]
make && make install
I made sure to put
extension=/usr/lib/php/20170718/redis.so
into the php.ini file as shown when I run echo phpinfo();
e.g.
/etc/php/7.1/cli/php.ini
When I run the inbuilt web server I get
PHP Warning: PHP Startup: Unable to load dynamic library
'/usr/lib/php/20170718/redis.so' - /usr/lib/php/20170718/redis.so:
undefined symbol: zend_empty_string in Unknown on line 0
Strangely PHPStorm autocompletes the PHP Redis class, so
$redis = new \Redis();
$redis->connect('127.0.0.1', 6379);
I can click into the Redis class and see it is the correct one.
I wonder if it is a version difference? Maybe because I am using 32-bit?
Another strange thing is, if I just put
extension=redis.so
in php.ini, it seems to be looking for an older build
PHP Startup: Unable to load dynamic library
'/usr/lib/php/20160303/redis.so' - /usr/lib/php/20160303/redis.so:
cannot open shared object file: No such file or directory in Unknown
on line 0
When I run
sudo apt-get install php-redis
it installs and means that no start up error shows, but the web page still shows a
Class 'Redis' not found
One other thing I notice is that in Apache, there is no error, and the class is found. But when I run php's inbuilt web server, the not found error shows up.
May you just need to install this using a ppa package like:
sudo apt-get install php7.1-redis
Ok so I noticed that phpinfo showed
PHP API 20160303
which means that the earlier error makes sense. The PHP version of the web server is 7.1, however, when running the phpredis phpize it shows the one for 7.2.
So I just made sure to remove php7.2-dev and re-install php7.1 via apt-get, then re-run the github repo steps above.

Drupal 8 installation setup shows older PHP version than what the server is running

When installing Drupal 8, just before database setup, I get a few errors and warnings, but I also see the following:
PHP
7.1.14-1+ubuntu16.04.1+deb.sury.org+1
However, doing php -v I get:
PHP 7.2.2-3+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Feb 6 2018 16:11:23) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.2-3+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
Clearly, my web server is running 7.2 but Drupal thinks it's 7.1. This is causing a problem where I have gd installed on PHP 7.2, but Drupal doesn't see gd installed on PHP 7.1 (because it isn't, at least its php.ini file doesn't have the gd extension enabled). Same with a few of the other errors and warnings.
How can I get Drupal 8 to recognize the correct PHP version?
So I figured it out:
Runing sudo a2dismod php7.1 then sudo a2enmod php7.2 seems to work perfectly (after a restart of Apache).
Try To install using composer
This method creates a project in web folder and other files outside web folder
composer create-project drupal-composer/drupal-project:8.x-dev d8_test_project --stability dev --no-interaction
Or
This method creates a project in a normal folder structure
composer create-project drupal/drupal my_site_name 8.*#dev --no-dev
I don't think it's about "recognizing" version, but you most likely have 2 different versions, one for console and other for web server. Run phpinfo() and see what PHP version is used by web server.

Categories