How to enable LDAP extension for PHP in Ubuntu - php

I am trying to enable LDAP for PHP5.6 on Ubuntu 16.04. I have tried the following steps
- sudo apt-get install php5-ldap
- sudo enmod ldap
- sudo php5enmod ldap
but still I am unable to get my ldap related functions working with PHP

you need to restart your apache (systemctl restart apache2). Apache has its very own single php-process running*. The php-configuration is only reload if apache restarts this process. You can check your active configuration with phpinfo
* this is very simplified and depends on the apache MPM-Module you are using.

sudo apt-get install php-ldap
/etc/init.d/apache2 restart
#baig772 answered their own question but they didn't post it as an answer.

latest ubunutu php-ldap was not working I tried installing apt-get install php7.0-ldap which is not working, then I download deb https://debian.pkgs.org/sid/debian-main-amd64/php7.2-ldap_7.2.4-1+b2_amd64.deb.html
wget http://ftp.br.debian.org/debian/pool/main/p/php-defaults/php-common_49_all.deb
wget http://ftp.us.debian.org/debian/pool/main/p/php7.0/php7.0-ldap_7.0.29-1+b2_amd64.deb
wget http://ftp.us.debian.org/debian/pool/main/u/ucf/ucf_3.0038_all.deb
then..
apt install ./php7.2-common_7.2.4-1+b2_amd64.deb
apt install ./php7.2-ldap_7.2.4-1+b2_amd64.deb
...
once it is installed confirmed by running the
apt-cache pkgnames | grep ldap | grep php
php-symfony-ldap
php7.2-ldap
php-net-ldap2
php-net-ldap3
check php enabled modules
:/usr/lib/php/7.2# php -m
ctype
curl
date
dom
fileinfo
filter
ftp
gd
hash
iconv
it does not have ldap module..
so copied .so files
:/usr/local/etc/php# cp /usr/lib/php/20170718/ldap.so /usr/local/lib/php/extensions/no-debug-non-zts-20170718/
enable apache ldap " a2enmod ldap"
php-m
now it has ldap module enabled.
[PHP Modules]
Core
ctype
curl
date
dom
fileinfo
filter
ftp
gd
hash
iconv
json
ldap
libxml
mbstring
restart apache and checked in info.php.
/etc/init.d/apache2 stop
/etc/init.d/apache2 start

Related

Install mailparse on linux centos7

Hi I'm trying to install mailparse for my php7.4.21 on my linux centos7 server but the documentation is not great and I'm no sysadin.
https://www.php.net/manual/en/mailparse.installation.php states "In order to use these functions you must compile PHP with mailparse support by using the --enable-mailparse configure option". This is not very helpful but so far I've had to do the following:
// To install re2c:
> curl http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/r/re2c-0.14.3-2.el7.x86_64.rpm --output re2c-0.14.3-2.el7.x86_64.rpm
> rpm -Uvh re2c-0.14.3-2.el7.x86_64.rpm
// I then installed mailparse
> pecl install mailparse
// I then modified php.ini to add the following:
extension=mailparse
// I then restarted apache
> systemctl restart httpd
But looking at my phpinfo output I cannot see mailparse listed.
What do I need to do next?
NOTE: I'm not sure I've actually "compiled PHP with mailparse" and I'm not sure how to apply "using the --enable-mailparse configure option".
Thanks
Abe
so I ended up on https://github.com/php-mime-mail-parser/php-mime-mail-parser/blob/master/README.md that talks about using sudo apt install php-cli php-mailparse for Ubuntu systems, which after a little more effort I found that yum install php-cli php-mailparse was the equivalent for centos (and then restarting apache). This worked.
yum install php-cli php-mailparse
systemctl restart httpd

problem with GD image extension on Amazon Linux 2

I've recently created LAMP servers on EC2 instances using Amazon Linux AMI.
using
sudo yum install -y php70-gd
I installed the GD extension.
This all worked fine and i could upload and manipulate images using PHP.
Now I've created a LAMP server using Amazon Linux 2 using the tutorial here :https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-lamp-amazon-linux-2.html
My problem is that I can't get the GD extension to work.
i tried using
sudo yum install -y gd
and this seemed to install an older version of GD.
I tried
sudo yum install php-gd
and this seems to install the latest version of the extension.
But the gd extension still doesn't seem to work.
when I enter
yum info gd
In the console it shows :
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
Installed Packages
Name : php-gd
Arch : x86_64
Version : 7.2.5
Release : 3.amzn2.0.2
Size : 769 k
Repo : installed
From repo : amzn2extra-lamp-mariadb10.2-php7.2
Summary : A module for PHP applications for using the gd graphics library
URL : http://www.php.net/
License : PHP and BSD
Description : The php-gd package contains a dynamic shared object that will add
: support for using the gd graphics library to PHP.
when I try an image resize script I get an error.
I've tried this test script :
$testGD = get_extension_funcs("gd"); // Grab function list
if (!$testGD){ echo "GD not installed."; exit; }
echo"<pre>".print_r($testGD,true)."</pre>";
and this gives me the result
GD not installed.
so obviously something is not right.
Can anyone help?
thanks
Amazon Linux 2 uses Apache with PHP-FPM instead of mod_php. So you need to restart the php-fpm process to reload PHP with the new extension.
sudo systemctl restart php-fpm
I'm running php 7.2.14 on Amazon Linux 2 and this worked for me:
$ sudo yum update -y
$ sudo yum install -y php-gd
$ sudo reboot
And solved...
Turns out restarting apache with
sudo systemctl restart httpd
wasn't enough to load the newly installed component...
what i needed to do was
sudo reboot
and everything works...
Why did't i try that 24 hours ago!
my PHP version was - PHP 7.2.18
$ php -v
I had to install -y php72-gd
$ sudo yum update -y
$ sudo yum install -y php72-gd
$ sudo reboot
$ sudo yum install -y php-gd
$ sudo systemctl restart php-fpm
No need to reboot
I was getting error Required extension GD is not loaded while using Claviska Simple Image Library in my project on AWS with Php 7.0
So I needed to update the GD php library:
sudo yum install -y php70-gd
and then restart httpd service to load the updated php.
sudo /etc/init.d/httpd restart
Worked for me!
You may have done nothing wrong and might not need to reboot either. Sometimes, the extensions are not directly mapped in the php.ini file. As such, you may need to map the newly added extensions (or which are not mapped already) in the php.ini file. In your case, add
extension=gd.so
In general,
extension=<my_extension_name>.so

installing imap on ubuntu for php7.1

How can one install imap for php in ubuntu for php7.1 preferably in the terminal.
There's some info on this on the php.net manual but it's a bit dated.
It talks about the c-client library and restarting apache afterwards etc
I'm still pretty new with linux
As long as it is part of the php repo you are using, this will be the package you are looking for.
sudo apt install php7.1-imap
You can install IMAP by following ways.
Step1: sudo apt-get install php7.1-imap
Step2: sudo phpenmod imap
Step3: php -m. Find out imap module
Step4: Run below command to confirm imap is install.
1. php -i | grep -i imap
2. dpkg -l | grep php7.1-imap
Step5: check phpinfo()
check imap is showing or not.
After enabling a module, you have to restart your pc. If a module is still not displayed in phpinfo(), please check on the next day.

Installing oci8 extension in linux for php?

I don't have a oracle database installed in my system. But i want to connect to the remote system. Do i just need to install oci8 extension library or i need to install both instantclient and the oci8 extension?
If I remember correctly, OCI8 extension wouldn't even compile without Instant Client; if you install using PECL, it asks you for Instant Client path. Moreover, from my experience, you'll also need Instant Client SDK in addition to Basic, unpack them to one directory, and make some symlinks before running PECL command:
sudo ln -s libclntsh.so.* libclntsh.so
sudo ln -s libocci.so.* libocci.so
Don't forget to enable the config later:
echo "; configuration for php oci8 module" | sudo tee /etc/php5/conf.d/oci8.ini
echo extension=oci8.so | sudo tee -a /etc/php5/conf.d/oci8.ini
Taken from this post (in Russian), also installed OCI8 myself recently on Debian 7.

Fatal error: Call to undefined function mcrypt_encrypt()

NOTE: The libraries MCrypt support depend on have not been updated in years and MCrypt should no longer be considered a viable or secure method of encrypting data. What's more, MCrypt has been deprecated in PHP 5, and removed entirely in PHP 7. If you have any code that runs MCrypt you should refactor it to use a more modern encryption library.
Does anyone know why this error message: (Call to undefined function mcrypt_encrypt() ) displays when I run the following code below?
Am I missing some steps perhaps any setting in PHP I have to do before this code can work?
$key = 'password to (en/de)crypt';
$string = 'string to be encrypted';
$test = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key),
$string, MCRYPT_MODE_CBC, md5(md5($key)));
If you have recently updated to ubuntu 14.04 here is the fix to this problem:
$ sudo mv /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available/
$ sudo php5enmod mcrypt
$ sudo service apache2 restart
What had worked for me with PHP version 5.2.8, was to open up php.ini and allow the php_mcrypt.dll extension by removing the ;, i.e. changing:
;extension=php_mcrypt.dll to extension=php_mcrypt.dll
For windows
;extension=php_mcrypt.dll to extension=php_mcrypt.dll
then restart your apache server
For Redhat
sudo yum install php55-mcrypt //if php5.5
sudo yum install php-mcrypt //if less than 5.4
sudo service httpd restart //if apache 2.4
sudo /etc/init.d/httpd restart //if apache 2.2 or less
For Ubuntu
sudo apt-get install php5-mcrypt
sudo service apache2 restart //if server not reloaded automatically
Still not working?
sudo php5enmod mcrypt && sudo service apache2 restart
If you are using PHP 7.2 or up:
This function was DEPRECATED in PHP 7.1.0, and REMOVED in PHP 7.2.0.
source: http://php.net/manual/en/function.mcrypt-encrypt.php
So you have to replace the php code and find a solution without mcrypt.
Or, I just found out, you can STILL use mcrypt in PHP 7.2.0, but you have to install it as a PHP Extension Community Library. (https://pecl.php.net/)
On Debian/Ubuntu Linux distros:
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
then:
sudo pecl install mcrypt-1.0.1
Source: https://www.techrepublic.com/article/how-to-install-mcrypt-for-php-7-2/
You don't have the mcrypt library installed.
See http://www.php.net/manual/en/mcrypt.setup.php for more information.
If you are on shared hosting, you can ask your provider to install it.
In OSX you can easily install mcrypt via homebrew
brew install php54-mcrypt --without-homebrew-php
Then add this line to /etc/php.ini.
extension="/usr/local/Cellar/php54-mcrypt/5.4.24/mcrypt.so"
Under Ubuntu I had the problem and solved it with
$ sudo apt-get install php5-mcrypt
$ sudo service apache2 reload
On ubuntu 14.10 :
Install module mcrypt
sudo apt install php5-mcrypt
Enable module mcrypt on apache2
sudo a2enmod mcrypt
Reload module configuration
sudo service apache2 restart
On Linux Mint 17.1 Rebecca - Call to undefined function mcrypt_create_iv...
Solved by adding the following line to the php.ini
extension=mcrypt.so
After that a
service apache2 restart
solved it...
I had the same issue for PHP 7 version of missing mcrypt.
This worked for me.
sudo apt-get update
sudo apt-get install mcrypt php7.0-mcrypt
sudo apt-get upgrade
sudo service apache2 restart (if needed)
Is mcrypt enabled? You can use phpinfo() to see if it is.
One more thing: if you are serving PHP via a web server such as Apache, try restarting the web server. This will "reset" any PHP modules that might be present, activating the new configuration.
Assuming you are using debian linux (I'm using Linux mint 12, problem was on Ubuntu 12.04.1 LTS server I ssh'ed into.)
I suggest taking #dkamins advice and making sure you have mcrypt installed and active on your php5 install. Use "sudo apt-get install php5-mcrypt" to install. My notes below.
Using PHP version PHP Version 5.3.10-1ubuntu3.4, if you open phpinfo() as suggested by #John Conde, which you do by creating test file on web server (e.g. create status page testphp.php with just the contents "" anywhere accessible on the server via browser)
I found no presence of enabled or disabled status on the status page when opened in browser. When I then opened the php.ini file, mentioned by #Anthony Forloney, thinking to uncomment ;extension=php_mcrypt.dll to extension=php_mcrypt.dll
I toggled that back and forth and restarted Apache (I'm running Apache2 and you can restart in my setup with sudo /etc/init.d/apache2 restart or when you are in that directory just sudo restart I believe)
with change and without change but all no go. I took #dkamins advice and went to install the package with "sudo apt-get install php5-mcrypt" and then restarted apache as above. Then my error was gone and my application worked fine.
If you are using php5-fpm do remeber to restart it, after installing mcrypt
service php5-fpm restart
If you using ubuntu 14.04 here is the fix to this problem:
First check php5-mcryp is already installed apt-get install php5-mcrypt
If installed, just run this two command or install and run this two command
$ sudo php5enmod mcrypt
$ sudo service apache2 restart
I hope it will work.
My Environment: Windows 10, Xampp Control Panel v3.2.4, PHP 7.3.2
Step-1: Download a suitable version for your system from here: https://pecl.php.net/package/mcrypt/1.0.3/windows
Step-2: Unzip and copy php_mcrypt.dll file to ../xampp/php/ext/
Step-3: Open ../xampp/php/php.ini file and add a line extension=php_mcrypt.dll
Step-4: Restart apache, DONE!
In Ubuntu 18.04, and for php7.0
$ sudo apt-get install php7.0-mcrypt
$ sudo systemctl reload apache2
for Linux based (Fedora)
yum -y install php-mcrypt
Enable the module by adding: 'extension=mcrypt.so' to PHP.ini. (/etc/php.ini)
systemctl restart httpd.service
Done!
For me it helped to uninstall mcrypt with:
sudo apt-get purge php5-mcrypt
and simply reinstall it:
sudo apt-get install php5-mcrypt
and dont forget to restart apache as described above.
Dont know why and how this was different in my case (using a vm with provisioned php55), but maybe this will help someone else. I also had this problem with some other modules like xcache...
Check and install php5-mcrypt:
sudo apt-get install php5-mcrypt

Categories