I want to update my php 5.3.3 to php 5.3.8, I already downloaded PHP5.3.8.tar.gzip.
My PHP 5.3.3 located in /usr/bin/php. When I try to install PHP5.3.8.tar.gzip and do this command:
./configure
make
make install
It installed in different location /usr/local/bin/php.
So now I have 2 php 5.3.3 and php 5.3.8. So I try to install it again and run this
./configure -prefix=/usr/bin/php
make
make install
This time an error occurred:
Installing PHP SAPI module: cgi
mkdir: cannot create directory `/usr/bin/php': File exists
mkdir: cannot create directory `/usr/bin/php/bin': Not a directory
make: [install-sapi] Error 1 (ignored)
Installing PHP CGI binary: /usr/bin/php/bin/
cp: accessing `/usr/bin/php/bin/#INST#29239#': Not a directory
make: *** [install-sapi] Error 1
Please help me, I want to delete the php5.3.8 I installed in /usr/local/bin/php
and update the /usr/bin/php to php5.3.8. I need php5.3.8 version only.
Thanks.
Generally on CentOS, you want to leave this sort of thing to yum.
yum update php
or
sudo yum update php
You can also replace the installation with a newer version. 5.3.X is not supported any longer, so you could do:
yum install yum-plugin-replace
yum replace php --replace-with php55
If you don't have php 5.5 in yum, first do this:
cd ~
wget http://dl.iuscommunity.org/pub/ius/stable/CentOS/6/x86_64/epel-release-6-5.noarch.rpm
wget http://dl.iuscommunity.org/pub/ius/stable/CentOS/6/x86_64/ius-release-1.0-11.ius.centos6.noarch.rpm
rpm -Uvh epel-release-6-5.noarch.rpm ius-release-1.0-11.ius.centos6.noarch.rpm
If you don't have wget installed:
yum install wget
PLEASE NOTE FOR ALL OTHERS FINDING THIS THROUGH GOOGLE!!!
The URL's that I linked in the wget commands are the current releases of the epel and ius repos for CentOS 6. (It may also be out of date.)
If you have RHEL or CentOS 5, you can find the specific link for your RPM here: http://dl.iuscommunity.org/pub/ius/stable/
Why do you need 5.3.8 specifically? The last version of 5.3 was 5.3.27. 5.3 is end-of-life. I would find a modern repo like remi and install 5.4 or later using yum
Apache is logging PHP Fatal error: Call to undefined function json_decode(). After some googling, it seems this problem is a result of not having the latest version of php. Oddly, running php --version ouputs
PHP 5.5.1-2+debphp.org~precise+2 (cli) (built: Aug 6 2013 10:49:43)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
with Zend OPcache v7.0.2-dev, Copyright (c) 1999-2013, by Zend Technologies
with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans
Clearly showing that my php version is greater than 5.1.
Any ideas as to what could cause this, or the steps to take to find out?
EDIT: The result of a script echoing phpversion is 5.5.1-2+debphp.org~precise
EDIT: The result of phpinfo() is also PHP Version 5.5.1-2+debphp.org~precise+2
Furthermore, in the phpinfo(), it lists the module JSON and the module authors (Omar Kilani, Scott MacVicar).
Using Ubuntu?
Short answer:
sudo apt-get install php7.2-json
(or php7.1-json or php5-json depending on the PHP version you're running)
Then of course make sure you restart Apache:
sudo service apache2 restart
Or if you are using PHP-FPM:
sudo service php7.2-fpm restart
(Or php7.1-fpm or php5-fpm)
Explanation
Debian has removed the previous JSON extension as of PHP 5.5rc2 due to a license conflict.
The JSON license has a clause which states:
The Software shall be used for Good, not Evil.
This causes a problem with Free Software Foundation's definition of free software which states:
The freedom to run the program, for any purpose (freedom 0).
FSF goes on to specifically list the JSON license as nonfree.
Yes it seems a bit silly. Nevertheless Debian has removed the non-compliant JSON extension, and instead offered a replacement extension that is functionally equivalent.
To be clear: PHP itself has NOT removed JSON, it's still in master. This is a distro / package manager issue.
Rasmus makes it pretty clear:
We have not removed json and we will never release a version of php without json support built in. Any changes in 5.5 is due to whatever distro packaging you are using which we have no control over.
More details
http://iteration99.com/2013/php-json-licensing-and-php-5-5/
http://liorkaplan.wordpress.com/2013/06/01/bye-bye-non-free-php-json-extension/
https://bugs.php.net/bug.php?id=63520
http://philsturgeon.co.uk/blog/2013/08/fud-cracker-php-55-never-lost-json-support
With Ubuntu :
sudo apt-get install php5-json
sudo service php5-fpm restart
Solution for LAMP users:
apt-get install php5-json
service apache2 restart
Source
As a RHEL 8 user, this was fixed with:
yum install php-json
And then reloading nginx and php-fpm. So basically the json libraries where missing from the default php install.
This should also work on CENTOS 8.
If you're using phpbrew try to install json extension to fix error with undefined function json_decode():
phpbrew ext install json
The same issue with 7.1
apt-get install php7.1-json
sudo nano /etc/php/7.1/mods-available/json.ini
Add json.so to the new file
Add the appropriate sym link under conf.d
Restart apache2 service (if needed)
I have the same question: PHP Fatal error: Call to undefined function json_decode(), but I run php under cygwin on Windows. When I run php -m, I found that there is no json module installed. So I run cygwin setup.exe again, check json package from the configuration interface, and the problem is solved.
The module was install but symbolic link was not in /etc/php5/cli/conf.d
you might also consider avoiding the core PHP module altogether.
It is quite common to use the guzzle json tools as a library in PHP apps these days. If your app is a composer app, it is trivial to include them as a part of a composer build.
The guzzle tool, as a library, would be a turnkey replacement for the json tool, if you tell PHP to autoinclude the tool.
http://docs.guzzlephp.org/en/stable/search.html?q=json_encode#
http://apigen.juzna.cz/doc/guzzle/guzzle/function-GuzzleHttp.json_decode.html
CENTOS
Scene
I installed PHP in Centos Docker, this is my DockerFile:
FROM centos:7.6.1810
LABEL maintainer="teran.a.joan#gmail.com"
RUN yum install httpd-2.4.6-88.el7.centos -y
RUN rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
RUN rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
RUN yum install php72w -y
ENTRYPOINT ["/usr/sbin/httpd", "-D", "FOREGROUND"]
The app returned the same error with json_decode and json_encode
Resolution
Install PHP Common that has json_encode and json_decode
yum install -y php72w-common-7.2.14-1.w7.x86_64
How to find the resolution?
I have another Docker File what build the container for the API and it has the order to install php-mysql client:
yum install php72w-mysql.x86_64 -y
If i use these image to mount the app, the json_encode and json_decode works!!
Ok..... What dependencies does this have?
[root#c023b46b720c etc]# yum install php72w-mysql.x86_64
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
* base: mirror.gtdinternet.com
* epel: mirror.globo.com
* extras: linorg.usp.br
* updates: mirror.gtdinternet.com
* webtatic: us-east.repo.webtatic.com
Resolving Dependencies
--> Running transaction check
---> Package php72w-mysql.x86_64 0:7.2.14-1.w7 will be installed
--> Processing Dependency: php72w-pdo(x86-64) for package: php72w-mysql-7.2.14-1.w7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: php72w-mysql-7.2.14-1.w7.x86_64
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: php72w-mysql-7.2.14-1.w7.x86_64
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.60-1.el7_5 will be installed
---> Package php72w-pdo.x86_64 0:7.2.14-1.w7 will be installed
--> Processing Dependency: php72w-common(x86-64) = 7.2.14-1.w7 for package: php72w-pdo-7.2.14-1.w7.x86_64
--> Running transaction check
---> Package php72w-common.x86_64 0:7.2.14-1.w7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================================
Package Arch Version Repository Size
========================================================================================================
Installing:
php72w-mysql x86_64 7.2.14-1.w7 webtatic 82 k
Installing for dependencies:
mariadb-libs x86_64 1:5.5.60-1.el7_5 base 758 k
php72w-common x86_64 7.2.14-1.w7 webtatic 1.3 M
php72w-pdo x86_64 7.2.14-1.w7 webtatic 89 k
Transaction Summary
========================================================================================================
Install 1 Package (+3 Dependent packages)
Total download size: 2.2 M
Installed size: 17 M
Is this ok [y/d/N]: y
Downloading packages:
(1/4): mariadb-libs-5.5.60-1.el7_5.x86_64.rpm | 758 kB 00:00:00
(2/4): php72w-mysql-7.2.14-1.w7.x86_64.rpm | 82 kB 00:00:01
(3/4): php72w-pdo-7.2.14-1.w7.x86_64.rpm | 89 kB 00:00:01
(4/4): php72w-common-7.2.14-1.w7.x86_64.rpm | 1.3 MB 00:00:06
--------------------------------------------------------------------------------------------------------
Total 336 kB/s | 2.2 MB 00:00:06
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : 1:mariadb-libs-5.5.60-1.el7_5.x86_64 1/4
Installing : php72w-common-7.2.14-1.w7.x86_64 2/4
Installing : php72w-pdo-7.2.14-1.w7.x86_64 3/4
Installing : php72w-mysql-7.2.14-1.w7.x86_64 4/4
Verifying : php72w-common-7.2.14-1.w7.x86_64 1/4
Verifying : 1:mariadb-libs-5.5.60-1.el7_5.x86_64 2/4
Verifying : php72w-pdo-7.2.14-1.w7.x86_64 3/4
Verifying : php72w-mysql-7.2.14-1.w7.x86_64 4/4
Installed:
php72w-mysql.x86_64 0:7.2.14-1.w7
Dependency Installed:
mariadb-libs.x86_64 1:5.5.60-1.el7_5 php72w-common.x86_64 0:7.2.14-1.w7
php72w-pdo.x86_64 0:7.2.14-1.w7
Complete!
Yes! Inside the dependences is the common packages. I Installed it into my other container and it works! After, i put de directive into DockerFile, Git commit!! Git Tag!!!! Git Push!!!! Ready!
cPanel
Go to MultiPHP INI Editor and select the Editor Mode tab, enter the following to enable JSON extensions:
extension=json.so
Or, if you have an existing php.ini file in your root directory, check if this extension is listed and make sure it's not commented out (preceded by semi-colon).
I have a problem with the update on php 5.4.9 (i install it with the ppa "ppa:ondrej/php5")
Now i have the problem that i can't install libssh2-php (which is required on my project)
I found some .deb files, but it's only for 32-bit systems.
So when i'm trying to install libssh2-php i have a collision with "libssh2-php:i386" and i have the following dependiesmessage:
ucf:i386 libc6:i386 (>= 2.4) libssh2-1:i386 (>= 1.0) and phpapi-20090626+lfs:i386
System: Ubuntu Server 12.04 LTS x64 | PHP 5.4.9
I also got a warning on running "php -v"
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20100525/ssh2.so' - /usr/lib/php5/20100525/ssh2.so: cannot open shared object file: No such file or directory in Unknown on line 0
The problem is/was that the libssh2 is not aviable for PHP5.4.x AND a x64 system.
I have the same problem trying to use ondrej's ppa for ubuntu 10.04 LTS. It seams that he didn't include the sssh extension.
Apt-get tries to install the version from default package which runs into conflict (depends phpapi-20090626+lfs) with current installed version, isn't it?
Only my backup php cli script needs this extension to run. After trying to solve dependencies witout success, I switched to a shell_exec('ssh ...#...') solution as workaround.
I am only a developer with advanced admin knowledge, no apt-get or linux packaging admin professional. There maybe other solution to fix this via packaging management or maybe building the needed version from source?
EDIT:
There will be another nicer solution :-) you can use pecl to install / build the extension, here is what i have done:
$ sudo pecl install ssh2
Failed to download pecl/ssh2 within preferred state "stable", latest release is version 0.12, stability "beta", use "channel://pecl.php.net/ssh2-0.12" to install
install failed
$ sudo pecl install channel://pecl.php.net/ssh2-0.12
downloading ssh2-0.12.tgz ...
Starting to download ssh2-0.12.tgz (26,223 bytes)
[...]
Build process completed successfully
Installing '/usr/lib/php5/20100525+lfs/ssh2.so'
install ok: channel://pecl.php.net/ssh2-0.12
configuration option "php_ini" is not set to php.ini location
You should add "extension=ssh2.so" to php.ini
Afterwards I add extension=/usr/lib/php5/20100525+lfs/ssh2.so to php config.
Just do:
sudo aptitude purge php5-suhosin
It's described in detail here: bugs.debian.org
ORIGINAL POST
First of all, I want to install memcached, not memcache.
I'm trying to set up memcached to work with my lampp server on ubuntu 12.10 since yesterday. I've already followed almost every tutorial I could find. The most recent thing, I tried to do was:
in terminal
apt-get install libmemcached-dev
cd /opt/lampp
./bin/pecl install memcached
and then adding extension="memcached.so" in php.ini file. After this I restarted lampp using /opt/lampp/lampp restart
When I tried to open php script in my browser it just got downloaded. Running tail -20 /opt/lampp/logs/php_error_logthis is what I see:
PHP Warning: PHP Startup: Unable to load dynamic library '/opt/lampp/lib/php/extensions/no-debug-non-zts-20100525/memcached.so' - /opt/lampp/lib/php/extensions/no-debug-non-zts-20100525/memcached.so: wrong ELF class: ELFCLASS64 in Unknown on line 0
It seems this guy had same problem but with different extension. When I try to compile 32 bit version of the extension using:
phpize
CFLAGS=-m32 CPPFLAGS=-m32 CCASFLAGS=-m32 ./configure
make
But make throws the following error:
/usr/bin/ld: skipping incompatible /usr/local/lib/libmemcached.so when searching for -lmemcached
/usr/bin/ld: cannot find -lmemcached
/usr/bin/ld: cannot find -lz
collect2: error: ld returned 1 exit status
make: *** [memcached.la] Error 1
The problem is that I don't even know if I'm on the right path. If someone could write short step-by-step guide how to get this working or just show me where the issue is it would be great.
UPDATE
After executing sudo dpkg --add-architecture i386 sudo apg-get update sudo apt-get install libmemcached-dev:i386 libz-dev:i386 and phpize CFLAGS=-m32 CPPFLAGS=-m32 CCASFLAGS=-m32 ./configure make memcached compiles fine. It still doesn't work however. After checking php error logs again I get this
PHP Startup: Unable to load dynamic library '/opt/lampp/lib/php/extensions/no-debug-non-zts-20100525/memcached.so' - /opt/lampp/lib/libgcc_s.so.1: version `GCC_4.2.0' not found (required by /usr/lib/i386-linux-gnu/libstdc++.so.6) in Unknown on line 0
You are on the right path - your lampp is 32bit while rest of the system (i assume) is 64bit. So when you installed libmemcached an compiled php-libmemcached it is 64bit version. That's why you get the "Wrong ELF class" error.
Before you can compile 32bit version of php-memchached you need to install 32bit versions of libmemcached and libz (and their headers).
You need to:
sudo dpkg --add-architecture i386
sudo apg-get update
sudo apt-get install libmemcached-dev:i386 libz-dev:i386
I think that should be enough to let you compile 32bit version of php-libmemcached.
There is a dirt way to fix your problem
go to /usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.x.x
and copied the libgcc_s.so into
/opt/lampp/lib and renamed it to libgcc_s.so.1 to overwrite the previous file.
What is the best way to get PHP 5.3 up and running on CentOS 5.4.
My machine says I have PHP 5.3 installed but running into an issue with my script that says
Fatal error: Class 'PDO' not found in /var/www/html/lib/rb.php on line 45
It fails trying to new up a PDO class in the RedbeanPHP 3.0 lib.
How can I fix this missing PDO problem?
I tried to follow these instructions:
from http://www.computingunplugged.com/issues/issue201102/00002619002
rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
# THIS LINE FAILED FOR ME
rpm -Uvh http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/i386/ius-release-1.0-6.ius.el5.noarch.rpm
yum erase php php-pear php-mysql php-cli php-common
yum install php53u php53u-pear php53u-cli php53u-common php53u-gd
yum install php53u-mbstring php53u-mcrypt php53u-mysql php53u-soap
yum install php53u-xml php53u-xmlrpc php53u-bcmath
UPDATE
Someone removed their answer. It was good. I'm putting it back in with exact steps.
First I had to yum install php53u-devel
To quote "
You need the PDO extension. Usually the best way to install extensions is via PECL.
Before you can install any PECL extensions you need to install the php5-dev package
sudo pecl install pdo
sudo pecl install pdo_mysql
You then need add the following to the end of your php.ini file(s). Depending on which version of PHP you installed they’ll be /etc/php5/apache2/php.ini, /etc/php5/cgi/php.ini and /etc/php/cli/php.ini.
extension=pdo.so
extension=pdo_mysql.so
"
Now I get a mysql_query_missing when trying to run sudo pecl install pdo_mysql
and not sure how to get past this.
You'll have to install the php-pdo package as well.
Edit: Maybe this helps as well: How do I enable PDO using CentOS?
I have been successfully able to install PHP-5.3 on CentOS 5.4 Linux. I needed this to be able to successfully install and run Drupal 7 - which also worked out for me. Here are the details:
This is a copy of the answer I wrote up in ServerFault: https://serverfault.com/a/392168/29205
(...for my question: https://serverfault.com/questions/391772/php-xml-install-complains-of-dependency-php-common-but-this-is-already-installed/392168#392168 )
The solution is based on the accepted answer in:
https://serverfault.com/questions/391839/how-to-force-centos-yum-to-use-a-later-version-of-a-package-dependency-already-i
In summary: move to php5.3.
Reason: support for php5.2 as been removed owing to security issues as explained in that other question's accepted answer. This removal causes mismatch of the versions of the dependencies and therefore the error seen.
Background
I wanted to run Drupal 7 on a CentOS 5.4 machine. So I needed 5.3 version of PHP.
Here are the full working steps to upgrade to PHP 5.3 with working repositories as of May 24 2012 ( I provide comments preceded by # - you don't need these, just for your info)
# Comment: sites like http://www.computingunplugged.com/issues/issue201102/00002619001
# provide a good start for remedying the problem whereby we need 5.3 on CentOS 5.4 to run Drupal 7. But although their packages worked at the time, the links are now outdated, and updates to these are below.
# comment: (as of May 2012 - the following work, the reason for failures was use of 1) older packages no longer on the server and 2) change of address of one of the servers to dl.fedoraproject.org/pub/epel (credit to: http://osdir.com/ml/centos/2012-03/msg00057.html )
rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
rpm -Uvh http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/i386/ius-release-1.0-10.ius.el5.noarch.rpm
yum erase php php-pear php-mysql php-cli php-common
yum install php53u php53u-pear php53u-cli php53u-common php53u-gd
yum install php53u-mbstring php53u-mcrypt php53u-mysql php53u-soap
yum install php53u-xml php53u-xmlrpc php53u-bcmath
# After doing the above, php -v shows 5.3.x But on attempting to install Drupal 7 you may get complaint of something "Your PHP installation is too old 5.1.6 Drupal requires at least PHP 5.2.4. See the system requirements page for more information." and php.info shows the same
# The remedy is to simply restart your apache server
service httpd restart
# credit to following for suggesting service httpd restart :-
# https://serverfault.com/a/207806/29205
# https://serverfault.com/questions/207762/centos-updating-php-via-yum-doesnt-change-the-version-apache-uses
# Drupal 7 install on CentOS 5.4 worked after applying the above steps
# If your MySQL server is not running (check by ps -ef | grep mysql ) then you can run:
/etc/init.d/mysqld
# ...to start it, and to make sure it starts when the machine is restarted or cold booted:
chkconfig mysqld on