After I use yum installed the php7.0:
yum install php70w
now how to start it?
# whereis php
php: /usr/bin/php /usr/lib64/php /etc/php.d /etc/php.ini /usr/local/bin/php /usr/share/php /usr/share/man/man1/php.1.gz
I also can not find the php-fpm:
# find / -name php-fpm
I installed apache, in /usr/local/httpd/.
EDIT-1
# yum install php7.0 libapache2-mod-php7.0
loaded:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* epel: mirror.premi.st
* extras: mirrors.163.com
* updates: mirrors.163.com
* webtatic: sp.repo.webtatic.com
No package php7.0
No package libapache2-mod-php7.0
Error: there is no ..
First To see the available options for PHP modules and libraries, you can type this into your system:
sudo yum search php-
The results are all optional components that you can install. It will give you a short description for each:
php-bcmath.x86_64 : A module for PHP applications for using the bcmath library
php-cli.x86_64 : Command-line interface for PHP
php-common.x86_64 : Common files for PHP
php-dba.x86_64 : A database abstraction layer module for PHP applications
php-devel.x86_64 : Files needed for building PHP extensions
php-embedded.x86_64 : PHP library for embedding in applications
php-enchant.x86_64 : Enchant spelling extension for PHP applications
php-fpm.x86_64 : PHP FastCGI Process Manager
php-gd.x86_64 : A module for PHP applications for using the gd graphics library
. . .
To get more information about what each module does, you can either search the internet, or you can look at the long description in the package by typing:
yum info package_name
There will be a lot of output, with one field called Description which will have a longer explanation of the functionality that the module provides.
For example, to find out what the php-fpm module does, we could type this:
sudo yum info php-fpm
Along with a large amount of other information, you'll find something that looks like this:
. . .
Summary : PHP FastCGI Process Manager
URL : http://www.php.net/
License : PHP and Zend and BSD
Description : PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI
: implementation with some additional features useful for sites of
: any size, especially busier sites.
If, after researching, you decide you would like to install a package, you can do so by using the yum install command like we have been doing for our other software.
If we decided that php-fpm is something that we need, we could type:
sudo yum install php-fpm
If you want to install more than one module, you can do that by listing each one, separated by a space, following the yum install command, like this:
sudo yum install package1 package2 ...
At this point, your LAMP stack is installed and configured. We should still test out our PHP though.
Related
I can't install any package related PHP, I get a yum error: No package php available.
My PHP version is 5.4.37 on Centos 7. I installed remi for other purposes and I think that the repository is not compatible with PHP version but I don't know how to fix it.
[root#server ~]# sudo yum install php php-pear
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centosmirror.netcup.net
* epel: mirrors.n-ix.net
* extras: centosmirror.netcup.net
* remi: mirror5.layerjet.com
* remi-safe: mirror5.layerjet.com
* updates: centosmirror.netcup.net
No package php available.
No package php-pear available.
Error: Nothing to do
You have, in yum configuration:
exclude=apache* httpd* mod_* mysql* MySQL* mariadb* da_* ftp exim* sendmail* php* bind-chroot*
This is very probably a "panel" enabled server (cpanel or others), which provides its own PHP stack.
So by design, you cannot install "php*" packages from standard repository or any other 3rd party repository. Such distribution is so altered, that it is often considered as "Not CentOS".
So, better to ask your php stack provider for how to update it (if possible, without breaking the panel application)
As suggested in other answer, this may be related to excludes set in yum.conf
The command below allows to run the installation of excluded packages without modifying the conf file:
yum --disableexcludes=main install php
BUT
It seems like it might be better to re-install PHP by the means of the control panel installed. IE Cpanel - EasyApache..
I have an unmanaged VPS server preinstalled with CentOs 6.6 and WHM/CPanel. I am trying to install php-ldap but it just says package not found. I have not been able to find anywhere what repository it should be in. How can I install ldap on my server to work with php 5.4? I am trying to manage Windows Server 2012 R2 Active Directory.
root#vps [~]# yum install php-ldap
Loaded plugins: fastestmirror, security
Setting up Install Process
Loading mirror speeds from cached hostfile
* base: mirror.5ninesolutions.com
* epel: fedora-epel.mirror.lstn.net
* extras: centos.arvixe.com
* updates: pubmirrors.dal.corespace.com
No package php-ldap available.
Error: Nothing to do
root#vps [~]#
On a cpanel serveur you probably have an "exclude" line in yum.conf (see I can't install any package related to PHP with yum) which prevent you to install/upgrade php from another repository.
To see the provider of "php", user this command
rpm -qf $(which php)
And the ldap extension, if available will be in the same namespace.
Notice switch the php stack from the cpanel provider to another repo can break it.
You need to understand that the base repos typically don't contain boutique builds for PHP. Your best bet is to install a different repo, like the Remi repo, which does contain that RPM.
While I'm at it, PHP 5.4 went End-of-life 4 days ago. Remi offers 5.5 and 5.6 so you should consider upgrading
Get the php version you are running by
php -v
if not worked try
rpm -qa |grep php
if the php version is 5.4 then use
sudo yum install php54w-ldap
if 5.6
sudo yum install php56w-ldap
and so on.
I am on centos 6.5 and when I install do yum install php-common it goes ahead and installs some packages, but php is still not installed. And, when I want to install php directly it is says php-common is causing conflict and does install the php module or even php-cli independently.
What is php-common used for?
To answer the question, here's what's in php-common on Redhat Enterprise 6.4 version of the package:
[marc#foo ~]$ rpm -ql php-common
/etc/php.d
/etc/php.d/curl.ini
/etc/php.d/fileinfo.ini
/etc/php.d/json.ini
/etc/php.d/phar.ini
/etc/php.d/zip.ini
/etc/php.ini
/usr/lib64/php
/usr/lib64/php/modules
/usr/lib64/php/modules/curl.so
/usr/lib64/php/modules/fileinfo.so
/usr/lib64/php/modules/json.so
/usr/lib64/php/modules/phar.so
/usr/lib64/php/modules/zip.so
/usr/lib64/php/pear
/usr/share/doc/php-common-5.3.3
/usr/share/doc/php-common-5.3.3/CODING_STANDARDS
/usr/share/doc/php-common-5.3.3/CREDITS
/usr/share/doc/php-common-5.3.3/EXTENSIONS
/usr/share/doc/php-common-5.3.3/INSTALL
/usr/share/doc/php-common-5.3.3/LICENSE
/usr/share/doc/php-common-5.3.3/NEWS
/usr/share/doc/php-common-5.3.3/README.EXTENSIONS
/usr/share/doc/php-common-5.3.3/README.EXT_SKEL
/usr/share/doc/php-common-5.3.3/README.MAILINGLIST_RULES
/usr/share/doc/php-common-5.3.3/README.PARAMETER_PARSING_API
/usr/share/doc/php-common-5.3.3/README.PHP4-TO-PHP5-THIN-CHANGES
/usr/share/doc/php-common-5.3.3/README.REDIST.BINS
/usr/share/doc/php-common-5.3.3/README.RELEASE_PROCESS
/usr/share/doc/php-common-5.3.3/README.SELF-CONTAINED-EXTENSIONS
/usr/share/doc/php-common-5.3.3/README.STREAMS
/usr/share/doc/php-common-5.3.3/README.SUBMITTING_PATCH
/usr/share/doc/php-common-5.3.3/README.SVN-RULES
/usr/share/doc/php-common-5.3.3/README.TESTING
/usr/share/doc/php-common-5.3.3/README.TESTING2
/usr/share/doc/php-common-5.3.3/README.UNIX-BUILD-SYSTEM
/usr/share/doc/php-common-5.3.3/README.WIN32-BUILD-SYSTEM
/usr/share/doc/php-common-5.3.3/README.input_filter
/usr/share/doc/php-common-5.3.3/README.namespaces
/usr/share/doc/php-common-5.3.3/TSRM_LICENSE
/usr/share/doc/php-common-5.3.3/ZEND_CHANGES
/usr/share/doc/php-common-5.3.3/ZEND_LICENSE
/usr/share/doc/php-common-5.3.3/php.ini-development
/usr/share/doc/php-common-5.3.3/php.ini-production
/usr/share/doc/php-common-5.3.3/regex_COPYRIGHT
/usr/share/php
/var/lib/php
As you can see, it basically contains the .so modules for curl, zip, fileinfo, json, and phar, plus license/support files.
What is package php-common and what does it ?
Its is a php package that includes common files for PHP packages, this package contains common utilities shared among all packaged PHP versions. The php-common package contains files used by both the php package and the php-cli package.
Package: php-common
The php-common package provides followings commands to manage PHP modules:
phpenmod – Used to enable modules in PHP
phpdismod – Used to disable modules in PHP
phpquery – Used to view status of modules of PHP
Use phpenmod command followed by module name to enable specific PHP module on your system:
### Syntax
$phpenmod MODULE_NAME
You can also define the PHP version using -v switch to enable specific modules:
### Syntax
$phpenmod -v <PHP VERSION> <MODULE NAME>
You can also disable any un-necessary PHP modules from your system using phpdismod command:
$phpdismod mbstring
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).
How do I install mbstring with PHP on CentOS 6.2
I've tried:
$ sudo yum install php-mbstring
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
* base: mirror.net.cen.ct.gov
* extras: centos.aol.com
* updates: mirrors.seas.harvard.edu
Setting up Install Process
No package php-mbstring available.
Error: Nothing to do
But no packages were found?
do the following:
sudo nano /etc/yum.repos.d/CentOS-Base.repo
under the section updates, comment out the mirrorlist line (put a # in front of the line), then on a new line write:
baseurl=http://centos.intergenia.de/$releasever/updates/$basearch/
now try:
yum install php-mbstring
(afterwards you'll probably want to uncomment the mirrorlist and comment out the baseurl)
If you have cPanel hosting you can use Easy Apache to do this through shell. These are the steps.
Type the Easy Apache PathType the path for Easy Apache
root#vps#### [~]# /scripts/easyapache
Do not say yes to the "cPanel update available".
Continue through the screens with defaults till you get to the "Exhaustive options list".
Page down till you see the Mbstring extension listed and select it.
Continue through the Steps and Save the Apache PHP build.
Apache and PHP will now rebuild to include the mbstring extension. Wait for the process to finish ~10 to 30 minutes. Once the process is finished you should see the Mbstring extension in the phpinfo now.
For more detailed steps see the article
Installing the mbstring extension with Easy Apache
Please check your /etc/yum.conf file, maybe it is exclude php packages.
You should remove php* from this line so you can download php-* packages:
exclude= courier* dovecot* exim* filesystem httpd* mod_ssl* mydns* php*
It's seems your server having some scripts like cPanel
*Make sure you update your linux box first
yum update
In case someone still has this problem, this is a valid solution:
centos-release : rpm -q centos-release
Centos 6.*
wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm -Uvh remi-release-6*.rpm
Centos 5.*
wget http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/5/x86_64/epel-release-5-4.noarch.rpm
rpm -ivh epel-release-5-4.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
rpm -Uvh remi-release-5*.rpm
Then just do this to update:
yum --enablerepo=remi upgrade php-mbstring
Or this to install:
yum --enablerepo=remi install php-mbstring
Find out php version - php -v
Search for php extensions available - yum search php-
Install using - yum install ea-php56-php-mbstring.x86_64
Then httpd -k restart
Package name - ea-php-php-mbstring.x86_64
yum install php-mbstring (as per http://php.net/manual/en/mbstring.installation.php)
I think you have to install the EPEL repository http://fedoraproject.org/wiki/EPEL
None of above works for godaddy server centOS 6, apache 2.4, php 5.6
Instead, you should
Install the mbstring PHP Extension with EasyApache
check if you already have it by, putty or ssh
php -m | grep mbstring
[if nothing, means missing mbstring]
Now you need to goto godaddy your account page,
click manager server,
open whm ----- search for apache,
open "easy apache 4"(my case)
Now you need customize currently installed packages,
by
click "customize" button on top line next to "currently installed package..."
search mbstring,
click on/off toggle next to it.
click next, next, .... privision..done.
Now you should have mbstring
by check again at putty(ssh)
php -m | grep mbstring [should see mbstring]
or you can find mbstring at phpinfo() page
As yum install php-mbstring then httpd -k restart didn't do it for me, I think these options should be compiled, as documented here:
Now, configure and build PHP. This is where you customize PHP with
various options, like which extensions will be enabled. Run
./configure --help for a list of available options. In our example
we'll do a simple configure with Apache 2 and MySQL support.
If you built Apache from source, as described above, the below example
will match your path for apxs, but if you installed Apache some other
way, you'll need to adjust the path to apxs accordingly. Note that
some distros may rename apxs to apxs2.
cd ../php-NN
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --enable-mbstring
make
make install
If you decide to change your configure options after installation,
you'll need to re-run the configure, make, and make install steps. You
only need to restart apache for the new module to take effect. A
recompile of Apache is not needed.
Note that unless told otherwise, 'make install' will also install
PEAR, various PHP tools such as phpize, install the PHP CLI, and more.
Though this page says it's optional:
--enable-mbstring
Allows multibyte character string support. This is optional, as slower custom code will be used if not available.
I have experienced the same issue before. In my case, I needed to install php-mbstring extension on GoDaddy VPS server. None of above solutions did work for me.
What I've found is to install PHP extensions using WHM (Web Hosting Manager) of GoDaddy. Anyone who use GoDaddy VPS server can access this page with the following address.
http://{Your_Server_IP_Address}:2087
On this page, you can easily find Easy Apache software that can help you to install/upgrade php components and extensions. You can select currently installed profile and customize and then provision the profile. Everything with Easy Apache is explanatory.
I remember that I did very similar things for HostGator server, but I don't remember how actually I did for profile update.
Edit:
When you have got the server which supports Web Hosting Manager, then you can add/update/remove php extensions on WHM. On godaddy servers, it's even recommended to update PHP ini settings on WHM.
sudo yum install php<version>w-mbstring
ex.
sudo yum install php56w-mbstring
If none of the above help you out, and you have the option, try obtaining one of the rpm files eg:
wget http://rpms.famillecollet.com/enterprise/6/remi/x86_64/php-mbstring-5.4.45-2.el6.remi.x86_64.rpm
then using rpm, install it ignoring the depenecies like so:
rpm -i --nodeps php-mbstring-5.4.45-2.el6.remi.x86_64.rpm
Hope that helps out.