how to use following commands using yum - php

I want to execute following commands using yum (redhat linux)
apt-get install build-essential libssl-dev
apt-get install gnupg libgpg-error-dev libassuan-dev libgpgme11-dev
apt-get install php5-dev php-pear

Installing gnupg prerequisite
yum install gcc libgpg-error gpgme gpgme-devel
after that
pecl install gnupg
configuration option “php_ini” is not set to php.ini location
You should add “extension=gnupg.so” to php.ini
Now, add the ‘gnupg.so‘ extension to ‘/etc/php.ini‘ file.
echo extension=gnupg.so >> /etc/php.ini
service httpd restart
php -m | grep gnupg
gnupg
That’s it.

Related

How to Install mcrypt PHP module

I am using Linux Mint 19.1. My PHP configuration is like below
I am getting below error while I am trying to install mcrypt.
Try out using these commands
To install the dependencies :
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

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

Installing pecl on debian

I'm trying to instal pecl_http on my server according to manual manual is for ubuntu, but apt-cache search pecl_http returned php5-pecl-http as pecl http packadge:
sudo apt-get update
sudo apt-get install php-pear php5-dev
sudo apt-get install php5-pecl-http
sudo apt-get install libcurl3-openssl-dev
in the end of php.ini added extension=http.so.
http_get() and func that I need http_parse_headers() says that func is undefined. What's the problem?
It's probably too late but for others a solution is explained here : http://www.mkfoster.com/2009/01/04/how-to-install-a-php-pecl-extensionmodule-on-ubuntu/
sudo apt-get update
sudo apt-get install php-pear php5-dev
sudo apt-get install libcurl3-openssl-dev
Then,
sudo pecl install pecl_http

How do you install Libevent for PHP?

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.

Installing PHP Zip Extension

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

Categories