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
Related
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
I am trying to update laravel using composer update on ubuntu 06.04 but everytime i run composer update this warning always comes up.
PHP Warning: PHP Startup: Unable to load dynamic library 'mcrypt.so' (tried: /usr/lib/php/20170718/mcrypt.so (/usr/lib/php/20170718/mcrypt.so: cannot open shared object file: No such file or directory), /usr/lib/php/20170718/mcrypt.so.so (/usr/lib/php/20170718/mcrypt.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Does anyone knows how to deal it?
I am using php7.2
I faced similar issue when I installed Php7.2 on Ubuntu 18. Though I had installed mcrypt using PECL still I get the error mentioned in the question.
I did following to fix it
sudo apt-get install php-pear php7.2-dev
then uninstalled
pecl uninstall mcrypt
Now reinstall mcrypt
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
When you are shown the prompt
libmcrypt prefix? [autodetect] :
Press [Enter] to autodetect.
After success installing mcrypt using pecl, you should add mcrypt.so extension to php.ini.
The output will look like this:
...
Build process completed successfully
Installing '/usr/lib/php/20170718/mcrypt.so' ----> this is our path to mcrypt extension lib
install ok: channel://pecl.php.net/mcrypt-1.0.1
configuration option "php_ini" is not set to php.ini location
You should add "extension=mcrypt.so" to php.ini
Now restart Apache
sudo service apache2 restart
Grab installing path and add to cli and apache2 php.ini configuration.
sudo bash -c "echo extension=/usr/lib/php/20170718/mcrypt.so > /etc/php/7.2/cli/conf.d/mcrypt.ini"
sudo bash -c "echo extension=/usr/lib/php/20170718/mcrypt.so > /etc/php/7.2/apache2/conf.d/mcrypt.ini"
First, open up a terminal window and install the necessary dependencies with the commands:
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
Once the dependencies have been installed, you can install mcrypt with the command:
sudo pecl install mcrypt-1.0.1
And there you go. Mcrypt is now installed. Go back to the process of installing whatever server software that depends upon this extension and you should be good to go.
For (>= PHP 7.3) you can use the following command:
sudo pecl install mcrypt-1.0.2
I faced this problem when I upgraded my PHP to 7.3
I found mcrypt.so was still present in /etc/php/7.3 that should not be as it is deprecated in php 7.3 so just deleting mcrypt.so from /etc/php/7.3 solved issue.
I used following commands:
cd /etc/php/7.3
sudo rm -rf mcrypt.so
sudo service apache2 restart
İts is worked for me.
export LC_ALL="C"
export LANG="C
sudo pecl install mcrypt-1.0.1
Also, if you're using php 7.2 & are getting this error and you know do not want/need mcrypt, but do not know how to exclude it.... You need edit your php.ini file and either comment this out by using a semi-colon in front of it:
; extension=mcrypt.so
or just delete that line entirely.
This is the extension that I am trying to install: https://github.com/EVODelavega/phpkafka
The messages passed to the queue should be in JSON format.
Currently, I am getting installation errors:
1. The instructions ask me to install librdkafka.
2. The installation link for the above step is this. I am unable to install using the 1st and 4th method. This is the error:
checking for librdkafka/rdkafka.h" in default path... not found
configure: error: Please reinstall the rdkafka distribution
Quick Install Steps:
Step 1 Install PHP pecl and pear commands:
sudo apt install php-pear
Step 2 Install librdkafka
sudo apt-get install -y librdkafka-dev
Step 3 Install PECL-package
sudo pecl install rdkafka
Step4 Enable PHP-extension in PHP config. Add to php.ini
sudo nano /etc/php/7.4/cli/php.ini
extension=rdkafka.so
Step 4 Restart apache server
sudo service apache2 restart
because you need another package librdkafka,you should install librdkafka first
$ git clone https://github.com/edenhill/librdkafka.git
$ cd librdkafka
$ ./configure
$ make && make install
this way can resolve your problem
For Linux Debian Stretch (9.13) actual flow is:
Install PHP pecl and pear commands:
sudo apt install php-pear
FYI: Depends on your installed PHP version you may need to use concrete version package. For example: php7.2-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
FYI: You need to restart php-fpm service to apply new config params.
I installed the libevent-dev library on my Debian 7 64bit desktop:
$ sudo aptitude install -y libevent-dev
Then I installed the PECL library
$ pecl list
Installed packages, channel pecl.php.net:
=========================================
Package Version State
libevent 0.1.0 beta
I've restarted PHP and the OS but PHP doesn't list libevent as an installed ext in with phpinfo() and I get "PHP Fatal error: Call to undefined function event_base_new()" when I try to use it.
How do you install Libevent?
Install Libevent for PHP 5.X
sudo apt-get install libevent-dev
sudo pecl install libevent-beta
sudo su
sudo echo 'extension=libevent.so' > /etc/php5/mods-available/libevent.ini
exit
sudo ln -s /etc/php5/mods-available/libevent.ini /etc/php5/fpm/conf.d/
sudo ln -s /etc/php5/mods-available/libevent.ini /etc/php5/cli/conf.d/
sudo service php5-fpm restart
Install Libevent for PHP 7.X
At this time pecl package libevent is not available for php 7
https://pecl.php.net/package/libevent
So let's compile it.
Download master:
https://github.com/expressif/pecl-event-libevent
Unpack to: /tmp/install_libevent
cd /tmp/install_libevent/pecl-event-libevent-master
sudo phpize
sudo ./configure
After this step scroll our console window and try find any Warnings or Errors. I got one warning - required to install re2c package.
sudo make
sudo make install
sudo su
sudo echo 'extension=libevent.so' > /etc/php/7.0/mods-available/libevent.ini
exit
sudo ln -s /etc/php/7.0/mods-available/libevent.ini /etc/php/7.0/fpm/conf.d/20-libevent.ini
sudo ln -s /etc/php/7.0/mods-available/libevent.ini /etc/php/7.0/cli/conf.d/20-libevent.ini
sudo service php7.0-fpm restart
I've successfully installed it.
These are the steps:
apt-get install libevent-dev
sudo pecl install libevent
Edit: Press enter when you are asked for the libevent installation directory (autodetect)
; Add extension=libevent.so in the *.ini file where you desire to load it. For example if you want this extension to be loaded always, create a libevent.ini file where your php5 mods are (in my computer they are in /etc/php5/mods-available/) and write extension=libevent.so. Enable this module then with php5enmod libevent. This page may help you.
Add extension=libevent.so to php.ini.
I'm attempting to install the PHP Zip extension.
My server does not have external internet access, so I downloaded it myself from PECL: http://pecl.php.net/package/zip. I chose 1.10.2, the latest "stable" release, and transferred it to my server.
I ran:
pear install zip-1.10.2.tgz
and added
extension=zip.so
to php.ini as instructed. I can see that zip.so was created and placed in the right extension_dir folder as well. I restarted apache and then checked to see if it was loaded by running:
php -m
Despite all of this, "zip" is still not in that list.
Am I missing a step or doing something wrong? I thought this should be really simple, and I'm starting to feel pretty dumb, haha.
Other probably important stuff:
CentOS
Apache 2.2.3
PHP 5.2.16
This is how I installed it on my machine (ubuntu):
php 7:
sudo apt-get install php7.0-zip
php 5:
sudo apt-get install php5-zip
Edit:Make sure to restart your server afterwards.
sudo /etc/init.d/apache2 restart or sudo service nginx restart
PS: If you are using centOS, please check above cweiske's answer
But if you are using a Debian derivated OS, this solution should help you installing php zip extension.
You may have several php.ini files, one for CLI and one for apache. Run php --ini to see where the CLI ini location is.
Simply use sudo yum install php-zip
for PHP 7.3 / Ubuntu
sudo apt install php7.3-zip
for PHP 7.4
sudo apt install php7.4-zip
1 Step - Install a required extension
sudo apt-get install libz-dev libzip-dev -y
2 Step - Install the PHP extension
pecl install zlib zip
3 Step - Restart your Apache
sudo /etc/init.d/apache2 restart
If does not work you can check if the zip.ini is called in your phpinfo, to check if the zip.so was included.
For php 7.3 on ubuntu 16.04
sudo apt-get install php7.3-zip
The best way to install the Zip extension in php7.2 on CentOS would be as below:
Find the available extention by searching with yum command
yum search zip
This will list all the zip packages. We need to look for the php7.2 zip package
Then if your php version is 7.2 then run the command
yum install ea-php72-php-zip
This will definetly resolve your issue.
Cheers !!
On Amazon Linux 2 and PHP 7.4 I finally got PHP-ZIP to install and I hope it helps someone else - by the following (note the yum install command has extra common modules also included you may not need them all):
sudo yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum -y install yum-utils
sudo yum-config-manager --enable remi-php74
sudo yum update
sudo yum install php php-cli php-fpm php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json
sudo pecl install zip
php --modules
sudo systemctl restart httpd
If you use php5.6 then execute this:
sudo apt-get install php5.6-zip
The PHP5 version do not support in Ubuntu 18.04+ versions, so you have to do that configure manually from the source files. If you are using php-5.3.29,
# cd /usr/local/src/php-5.3.29
# ./configure --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=MySQL_LOCATION/mysql --prefix=/usr/local/apache/php --with-config-file-path=/usr/local/apache/php --disable-cgi --with-zlib --with-gettext --with-gdbm --with-curl --enable-zip --with-xml --with-json --enable-shmop
# make
# make install
Restart the Apache server and check phpinfo function on the browser <?php echo phpinfo(); ?>
Note: Please change the MySQL_Location: --with-mysql=MySQL_LOCATION/mysql
I tried changing the repository list with:
http://security.ubuntu.com/ubuntu bionic-security main universe http://archive.ubuntu.com/ubuntu bionic main restricted universe
But none of them seem to work, but I finally found a repository that works running the following command
add-apt-repository ppa:ondrej/php
And then updating and installing normally the package using apt-get
As you can see it's installed at last.
I was trying to install it on CentOS 7 for php 7.1. In my case yum package php-zip was unavailable in remi repo, but I could install it using different name
yum install php-pecl-zip
So if you can't find it by query php-zip, try searching for php-pecl-zip.
For those who need to install the zip extension in a Docker image being built.
Dockerfile:
FROM php:8.1-apache
RUN apt-get update \
&& apt-get install -y libzip-dev \
&& docker-php-ext-install zip