Fail to install xdebug in Ubuntu with php7.2 - php

I'm trying to install xdebug in my recently upgraded Ubuntu 20.04.1
When I place the output of phpinfo() in https://xdebug.org/wizard
I get:
Installation Wizard
Summary
Xdebug installed: no
Server API: Apache 2.0 Handler
Windows: no
Zend Server: no
PHP Version: 7.2.34
Zend API nr: 320170718
PHP API nr: 20170718
Debug Build: no
Thread Safe Build: no
OPcache Loaded: no
Configuration File Path: /opt/lampp/etc
Configuration File: /opt/lampp/etc/php.ini
Extensions directory: /opt/lampp/lib/php/extensions/no-debug-non-zts-20170718
The installation recommends me to install the version: xdebug-3.0.1
But when I follow the instructions I get this error from the terminal:
The following packages have unmet dependencies:
php-dev : Depends: php7.4-dev but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
How can I solve this problem?
Should I install an older package of xdebug to be compatible with my php7.2 version?
Thanks in advance.

I solved the problem by installing php7.2-dev in my Ubuntu 20.04.1
sudo add-apt-repository ppa:ondrej/php -y
sudo apt-get update
sudo apt-get install php7.2-dev
After that I could run phpize and still use XDebug 3.

set php v7.2(optional)
update-alternatives --set php /usr/bin/php7.2
then set and update all needed for php7.2:
sudo add-apt-repository ppa:ondrej/php -y
sudo apt-get update
sudo apt-get install -y php7.2 php7.2-xdebug

Related

PHP Extensions activate in Ununtu

Ive installed an extension (rdkafka) to the server (ubuntu)
and added the extension to php.ini
extension=rdkafka.so
but when i go to phpinfo(), the rdkafka is not activated
when i try this command:
phpenmod rdkafka
i got this error:
WARNING: Module rdkafka ini file doesn't exist under /etc/php/7.3/mods-available
on extensions folder,, all the extensions colored green, except rdkafka is white
install PHP pecl and pear
sudo apt install php-pear
Add backports repository. Current ext-rdkafka depends on librdkafka version 0.11.0 or greater. So follow official instructions but use stretch-backports
Install librdkafka-dev package from backports:
sudo apt -t stretch-backports install librdkafka-dev
Update apt:
sudo apt update
Install PECL-package:
sudo pecl install rdkafka
Enable PHP-extension in PHP config. Add to php.ini:
extension=rdkafka.so
Restart apache
sudo apachectl -k restart

How to install mcrypt on PHP 7.3.3 ubuntu

I tried to follow:
PHP Warning: PHP Startup: Unable to load dynamic library 'mcrypt.so'
sudo apt-get -y install gcc make autoconf libc-dev pkg-config
sudo apt-get -y install php7.2-dev
sudo apt-get -y install libmcrypt-dev
sudo pecl install mcrypt-1.0.1
I get:
pecl/mcrypt requires PHP (version >= 7.2.0, version <= 7.3.0, excluded versions: 7.3.0), installed version is 7.3.3-1+ubuntu14.04.1+deb.sury.org+1
No valid packages found
install failed
I use prestashop which require this
If anyone is using an AWS bitnami install w/ php7.3.10, the following is a layout with appropriate file paths (references listed below)
Check your PHP version
$ php -version
Install mcrypt extension
$ sudo apt-get -y install gcc make autoconf libc-dev pkg-config
$ sudo apt-get -y install libmcrypt-dev
If php version > 7.3.0
$ sudo pecl install mcrypt-1.0.2
Or the newest version: https://pecl.php.net/package/mcrypt
If php version <= 7.3.0
$ sudo pecl install mcrypt-1.0.1
When you are shown the prompt (Press [Enter] to autodetect)
> libmcrypt prefix? [autodetect] :
enable mcrypt in php.ini -> check if mcrypt is already in php.ini and maybe just needs to be uncommented
$ more /opt/bitnami/php/etc/php.ini | grep mcrypt
;extension=mcrypt.so
Add or uncomment extension=mcrypt.so in php.ini
$ emacs /opt/bitnami/php/etc/php.ini
REFERENCES...
https://lukasmestan.com/install-mcrypt-extension-in-php7-2/
How to install mcrypt on PHP 7.3.3 ubuntu
https://stackoverflow.com/a/55678046/2298002
You have to install version 1.0.2.
The error message clearly tells you 1.0.1 supports only PHP 7.2, not 7.3.
It's all documented on the official pecl/mcrypt page.
Release 1.0.2:
PHP Version: PHP version 7.4.0 or older
PHP Version: PHP 7.2.0 or newer
PEAR Package: PEAR 1.4.0 or newer
Release 1.0.1:
PHP Version: PHP version 7.3.0 or older
PHP Version: PHP 7.2.0 or newer
PEAR Package: PEAR 1.4.0 or newer
Use this, it's working perfectly in php-7.3:
sudo apt-get -y install gcc make autoconf libc-dev pkg-config
sudo apt-get -y install libmcrypt-dev
sudo pecl install mcrypt-1.0.1
Autodetect: HIT ENTER
sudo bash -c "echo extension=/usr/lib/php/[folder in your pc]/mcrypt.so > /etc/php/7.3/cli/conf.d/mcrypt.ini"
sudo bash -c "echo extension=/usr/lib/php/[folder in your pc]/mcrypt.so > /etc/php/7.3/apache2/conf.d/mcrypt.ini"
php -i | grep mcrypt
I have solved same issue in PHP Version : 7.4.3 Ubuntu Version : 20.04.1 LTS and nginx
sudo apt-get install php-pear php7.4-dev
sudo apt-get -y install gcc make autoconf libc-dev pkg-config
sudo apt-get -y install gcc make autoconf libc-dev pkg-config
sudo apt-get -y install libmcrypt-dev
You can choose your mcrypt version according to php version Read
sudo pecl install mcrypt-1.0.4
When you are shown the prompt
libmcrypt prefix? [autodetect] :
Press [Enter] to autodetect.
The output will be something like this.
Build process completed successfully
Installing '/usr/lib/php/20190902/mcrypt.so'
install ok: channel://pecl.php.net/mcrypt-1.0.4
configuration option "php_ini" is not set to php.ini location
You should add "extension=mcrypt.so" to php.ini
After success installing mcrypt using pecl, you should add extension=/usr/lib/php/20190902/mcrypt.so extension to php.ini.
I have added extension=/usr/lib/php/20190902/mcrypt.so in bellow files
/etc/php/7.4/fpm/php.ini
/etc/php/7.4/cli/php.ini
Restart You nginx because i am using nginx
systemctl restart nginx
You can also restart php-fpm
sudo service php7.4-fpm restart
Finally how can verify mycrpt is installed or not (Note close your terminal and open again)
php -m | grep mcrypt

How to install PHP intl extension in Ubuntu 14.04

I have a hard time to find exact method to install PHP intl extension in Ubuntu 14.04.
I tried with sudo apt-get install php5-intl but displays error Unable to locate package.
I really need this extension for Zend Framework 2 , because of above missing extension I am getting error like this
ERROR: Zend\I18n\Validator component requires the intl PHP extension
I am using PHP 5.5.9.
How can I install PHP-intl extension in a correct way ?
For php5 on Ubuntu 14.04
sudo apt-get install php5-intl
For php7 on Ubuntu 16.04
sudo apt-get install php7.0-intl
For php7.2 on Ubuntu 18.04
sudo apt-get install php7.2-intl
Anyway restart your apache after
sudo service apache2 restart
IMPORTANT NOTE: Keep in mind that your php in your terminal/command
line has NOTHING todo with the php used by the apache webserver!
If the extension is already installed you should try to enable it. Either in the php.ini file or from command line.
Syntax:
php:
phpenmod [mod name]
apache:
a2enmod [mod name]
install it from terminal
sudo apt-get install php-intl
May be universe repository is disabled, here is your package in it
Enable it
sudo add-apt-repository universe
Update
sudo apt-get update
And install
sudo apt-get install php5-intl
In Ubuntu 20.04, PHP 7.4 use the following command:
sudo apt-get install php7.4-intl
replace 7.4 with your PHP version
So, I have problem with it. If you can't install see below.
And previously you have to add repository.
sudo add-apt-repository ppa:ondrej/php
2.1) sudo apt-add-repository ppa:ondrej/apache2
or
2.2) sudo add-apt-repository ppa:ondrej/nginx
After that you can install
sudo apt-get install php7.4-intl
Where 7.4 your php version.
For php 5.6 on ubuntu 16.04
sudo apt-get install php5.6-intl
sudo apt-get install php-intl
then restart your server
This method works for me to install PHP intl extension in Ubuntu 18.04 and nginx
sudo apt install php7.2-intl -y
you could search with
aptitude search intl
after you can choose the right one, for example
sudo aptitude install php-intl
and finally
sudo service apache2 restart
good Luck!

Cannot add PPA: 'ppa:ondrej/php5-5.6'

I'm trying to update my php 5.5.9 to 5.6 in an Ubuntu machine.
But when I run:
sudo add-apt-repository ppa:ondrej/php5-5.6
I'm getting:
Cannot add PPA: 'ppa:ondrej/php5-5.6'.
Please check that the PPA name or format is correct.
How can I fix this?
EDIT
I ran:
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php5
But when I run:
php5 -v
I still get php 5.5.9:
PHP 5.5.9-1ubuntu4.20 (cli) (built: Oct 3 2016 13:00:37)
add the right ppa first, do the following
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get -y install php5.6 php5.6-mcrypt php5.6-mbstring php5.6-curl php5.6-cli php5.6-mysql php5.6-gd php5.6-intl php5.6-xsl php5.6-zip
i had the same issue in installing the php5.6 then i did the above steps.
While the answer of #tanveerahmaddar provides crucial information, here is the correct way to install the PHP 5.6 on Ubuntu 12.04:
Important: If you plan to use PHP5.6 in websites (which you probably wish to), you have to upgrade to Apache 2.4, which does not ship with Ubuntu 12.04 (will cover the upgrade of Apache below)
Step 1: Check versions
# check PHP version
php -v
# check Apache version
apache2 -v
If your Apache version is 2.2, follow Step 2; if version is 2.4, skip to Step 3
Step 2: Add PHP5.6+ repository and update package list
add-apt-repository ppa:ondrej/apache2
apt-get update
apt-get upgrade
This step will upgrade Apache from 2.2 to 2.4. Re-configure your Apache if needed. Backup your existing Apache configurations, enabled sites and mods. You might need to re-install / upgrade some of the mods.
Step 3: Add PHP5.6+ Repository
add-apt-repository ppa:ondrej/php
apt-get update
Step 4: Install PHP 5.6
apt-get install -y php5.6 php5.6-mcrypt php5.6-mbstring php5.6-curl php5.6-cli php5.6-mysql php5.6-gd php5.6-intl php5.6-xsl php5.6-zip libapache2-mod-php5.6
This will install PHP 5.6 and some common packages such as cURL (php5.6-curl) and GD (lib5.6-gd), as well as enable PHP 5.6 in Apache 2.4 (libapache2-mod-php5.6).
Apache will be restarted during the process.
That's all steps you have to do.
Hint: If you want to upgrade to PHP 7 instead (off-topic), just issue the following command after Step 3 (skip Step 4):
apt-get dist-upgrade
Final words: Not recommend to upgrade to PHP 5.6 in Ubuntu 12.04, as it involves upgrading Apache to 2.4. Ubuntu 14.04 comes with Apache 2.4, which is a lot easier to upgrade PHP 5.6.
This work for perfectly for me.
Add the right PPA first, by doing the following
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get -y install php5.6 php5.6-mcrypt php5.6-mbstring php5.6-curl
php5.6-cli php5.6-mysql php5.6-gd php5.6-intl php5.6-xsl php5.6-zip
Disable php 5.5.3 or 5.5.9 module
a2dismod php5
Enable the just installed php5.6 module
a2enmod php5.6
Finally, you restart your apache
sudo service apache restart
#tanveer ahmad dar highlighted most of it.
This worked in my Ubuntu Server 14.04.5 LTS
a2dismod php5
a2enmod php5.6
apache2ctl restart

Ubuntu Server Installing PHP 7 WITHOUT Apache

I'm trying to get my server re-setup as a Lemp stack
The issue I am now running into is installing PHP 7 without Apache, since nGinx will be my webserver.
So, I've added ppa:ondrej/php. ran apt-get update, and tried to install just php7.0 via apt-get install php7.0
--nodeps flag does not work, as I am on Ubuntu 15.10
And I am presented with:
The following extra packages will be installed:
apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php7.0 libapr1
libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.1-0 libqdbm14
php-common php-readline php7.0 php7.0-cli php7.0-common php7.0-json
php7.0-opcache php7.0-readline
Suggested packages:
apache2-doc apache2-suexec-pristine apache2-suexec-custom php-pear
php-user-cache
The following NEW packages will be installed:
apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php7.0 libapr1
libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.1-0 libqdbm14
php php-common php-readline php7.0 php7.0-cli php7.0-common php7.0-json
php7.0-opcache php7.0-readline
I do not want apache anywhere near my server, so how can I install php7 without it? Short of compiling from source (as this makes it difficult at best to keep it updated)
If you just request php7.0, it'll install Apache as default. Do apt-get install php7.0-fpm and it'll install as FPM instead, leaving something like nginx up to you.
Use the command:
sudo apt install php7.2 php7.2-common php7.2-cli php7.2-fpm
It will require the php7.2 dependencies in strict mode (WITHOUT apache2).
On Ubuntu 18.04 I managed to do this successfully with:
sudo apt-get install php7.2-cli
In Ubuntu 20.04, php 7.4 is the default.
Thus, without adding any PPAs, all you need is
apt install php-fpm
This will bring in a few libraries, including php-cli, but NO apache-related things.
With the following steps you can install any PHP version you want, just replace 7.4 with your desired version.
Also I am suggesting to install the cli package because I assume you dont want to have fpm installed. Otherwise you can install php7.4-fpm instead.
Install ppa:ondrej/php repositories
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
Install PHP
sudo apt install php7.4-cli
You will get the following:
The following additional packages will be installed:
php-common php7.4-common php7.4-json php7.4-opcache php7.4-readline

Categories