How to enable LDAP with PHP 7.0 in Ubuntu server? - php

I have recently upgraded Ubuntu to version 16.04 and PHP to version 7. However, the ldap connection is not working.
How to enable ldap in PHP 7?

To install ldap on a lamp with PHP version 7.0 (or 7.1):
apt-get install php7.0-ldap (or use apt-get install php7.1-ldap )
service apache2 restart
After that create a php file to get the php configuration phpinfo();
Now ldap is installed.

Providing the php version number is no more required:
apt-get install php-ldap
Is enough now, the correct package version will be automatically installed.
PS: Note that is it true if you use the standard php packages provided by your distribution. If you are using an additional ppa for PHP like the sury one, you will have to specify the version number as there are multiple versions available.

install both php ldap for your specific php version, mine was
sudo apt install php7.2-ldap php-ldap -y
it solves the problem i was having

Related

how to upgrade from php 7.0 to php 7.3 on Debian 9.1

I have a Debian 9.1 droplet on DigitalOcean. 1GB Memory, 30GB Disk.
I've previously installed php 7.0 using
apt install php php-fpm
I also ran the following commands to install php modules:
apt-get install php-mysql
apt-get install php-curl
apt-get install php-zip
apt-get install php-apcu
apt-get install php-xml
How do I now upgrade from 7.0 to 7.3?
Just to give you an idea of how you can do it:
Basically, you need to follow two steps:
Install the 7.3 version as you did for 7.0 (you can pass the version number to install the exact version number)
You need to configure your PHP CLI to use the new version 7.3 instead of 7.0.
The above steps can be done for every version.
Here is documentation of how you can do it in case of migration from 7 to 8.
NOTE: The documentation will help you to install a version of PHP and configure CLI so you need to make sure to do the updates as per 7.3.
sudo-apt update
sudo apt-get install php-fpm
This will go try to update it if see you already have php-fpm...
Your repository should be updated to understand there is new version of php that is available for download
you can also remove & purge it and try to download it again...
but also consider some services needs to be updated and set to use last version of php that is currently installed...
Like Nginx ,in that you should update for .conf file to read php 7.3 or any installed versions
you can also check how many versions php do you have by going to directory by this command cd /etc/php and do ls

How do I install mcrypt for lampp in ubuntu 14.04 lts

I am new in php framework. So, I am trying to grasp the pros and cons of Laravel 4.2.11
But when I was going to install composer in the laravel's root folder in the htdocs folder of lampp, it showed warning in the terminal that it requires MCrypt PHP Extension.
By the way, I have another php installed in my PC in /usr/bin/php and its version is 5.5.9 and Lampp's php version is 5.6.12
phpinfo() of Lampp showed that It has mcrypt support and mcrypt_filter support, both are enabled.
What should I do to enable artisan to work for Lampp's php?
First ensure the mcrypt module is installed:
sudo apt-get install php5-mcrypt
Then:
sudo php5enmod mcrypt

utf8_(en|de)code removed from php7?

I recently switched to PHP 7 on my development server, which has worked just fine - until now.
Since I updated to PHP 7.0.3-10+deb.sury.org~trusty+1 (earlier today), the utf8_decode and utf8_encode functions are no longer accessible. They were, however, in previous versions of PHP7. When called, a fatal error is raised.
I read that these functions are provided by the mbstring extension, which I checked with var_dump(extension_loaded('mbstring')); is loaded.
How can I get the above functions to work again?
I had the same problem. Just install php7.0-xml package. Ubuntu 16.04:
sudo apt-get install php7.0-xml
Edit: Restart apache2 to load the new package.
On Ubuntu, you got the following message during the upgrade of PHP7:
php7.0 (7.0.3-6) unstable; urgency=medium
* Several extensions have been split into separate extension packages:
- php-dba - Database (dbm-style) Abstraction Layer
- php-mbstring - Multibyte String
- php-soap - SOAP
- php-xml - DOM, SimpleXML, WDDX, XML, XMLReader and XMLWriter
- php-zip - Zip
* The new packages are not installed automatically, so you will need to
install them by hand, if you use the functions in those modules.
* Most modules that have been builtin before are now included in
php7.0-common package and they are enabled by default for your
convenience. You can disable unneede modules via phpdismod tool.
-- Ondřej Surý <ondrej#debian.org> Mon, 22 Feb 2016 12:37:09 +0100
so it's one of those packages that's causing the problem. In this case, it's php-xml.
Note the
The new packages are not installed automatically
You can fix that by
sudo apt-get install php-xml
sudo apache2ctl graceful
If you are on CentOS, following command should work:
yum install php-xml
As the top voted answer did not work for me i found yet another package for php7 which (obvious by its name) fixed it for me
sudo apt-get install php7.0-mbstring
In Ubuntu 16.04 LTS, with php 5.6, try:
sudo apt-get install php5.6-xml
sudo service apache2 restart
The utf8_decode and utf8_encode functions are accessible in php 7:
function.utf8-encode - manual - php
This is because the php-xml package is missing in your php installation.
If your server is running Mandrake, enter "urpmi php-xml".
If your server is running EASYPHP on Windows, click on the EASYPHP logo to activate the php-xml module.
On debian or ubuntu try :
apt-get install php7.0-xmlrpc
I encountered the same problem and for me,
sudo apt-get install php-patchwork-utf8
and restarting the apache2 server solved the problem (on Ubuntu 16.04 LTS).

How to install "pthreads" on OSX, PHP 5.5.30

I couldn't find any step-by-step guide how to install this thing on OSX. And I don't want to recompile PHP, if that's possible.
Is there simply a package that I can install from somewhere that will just enable pthreads? I tried with:
pecl install pthreads
pecl/pthreads requires PHP (version >= 7.0.0RC5), installed version is 5.5.30
No valid packages found
Update php to version >= 7.0.0RC5 or install another version of pthreads
pecl install pthreads-2.0.10
Also pthreads will require that php is configurated with flag --enable-maintainer-zts. It is set on php compilation.
./configure ... --enable-maintainer-zts ...
make
make install

How to install V8js on PHP5.5?

I want to install the v8js extension for PHP5.5 on Ubuntu 12.04 but can't make it working.
When I try to install the v8js extension version 0.2.0 (latest) with PECL, I have this message:
configure: error: libv8 must be version 3.24.6 or greater
ERROR: `/tmp/pear/temp/v8js/configure --with-v8js' failed
If I try to install an old version, I have a compilation error. This message is very similar to my issue: Install v8js for php on ubuntu
How can I fix this issue?
EDIT: I couldn't install it on Ubuntu 14.04 with PHP5.5, even with a PHP downgrade with PHPbrew to PHP 5.4. However, using Ubuntu 12.04 with PHP 5.4 works great. I didn't try the downgrade from PHP 5.5 to 5.4 on Ubuntu 12.04.
in case you can't find libv8-dev or libv8-dbg, you can find the correct version by run command
~$ apt-cache search libv8
libv8-3.14-dbg - V8 JavaScript engine - debugging symbols
libv8-3.14-dev - V8 JavaScript engine - development files for 3.14 branch
libv8-3.14.5 - V8 JavaScript engine - runtime library
libv8-dev - V8 JavaScript engine - development files for latest branch
then you can run
~$ sudo apt-get install libv8-3.14-dev libv8-3.14-dbg g++ cpp
then you can try to install v8js via pecl by running
~$ sudo pecl install v8js-0.2.0
if that command return error like this
configure: error: libv8 must be version 3.24.6 or greater
ERROR: `/tmp/pear/temp/v8js/configure --with-v8js' failed
you can try to install v8js-0.1.3 instead by running
~$ sudo pecl install v8js-0.1.3
then edit your php.ini to add v8js extension
~$ echo "extension=v8js.so" >> /etc/php5/cli/php.ini
Open your terminal/console
sudo apt-get install libv8-dev libv8-dbg g++ cpp
Make an update sudo apt-get update
Try sudo pecl install v8js-0.2.0 (or other version i.e.: sudo pecl install v8js-0.1.3)
Edit your php.ini (Check: Where is my php.ini file?) file by adding: extension=v8js.so.
Restart server
If it the extension still doesn't work, try to edit /etc/php5/conf.d/v8js.ini and add extension=v8js.so and restart server again.
Hope this helps.
These other answers work well and I used v8js-0.1.3 for the past 1.5 years but after needing to upgrade to PHP 7 I needed a better solution as v0.1.3 doesn't compile with PHP 7 (something to do with php_smart_str being renamed to php_smart_string).
After a couple hours of frustrating research and compiling libv8 myself, I didn't want to have to go through this whole process on every server I provisioned.
Anyway, I found this site which points you to a launchpad PPA site that provides a couple different ubuntu packages with the 5.1 and 5.2 libv8 libraries.
I ran these commands (please don't add repositories of 3rd party devs without understanding the risks).
sudo apt-add-repository ppa:pinepain/libv8-5.2
sudo apt-get update
sudo apt-get install libv8-5.2-dev
sudo pecl install v8js-1.1.0
(Thanks #JeyKeu for suggesting to add "apt-get update" to these commands)
I couldn't get v8js-1.3.0 or 1.2.0 to build, but 1.1.0 worked well. I checked the changelog and found that the latest updates are not necessary in my circumstance anyway.

Categories